Search in sources :

Example 46 with InflaterInputStream

use of java.util.zip.InflaterInputStream in project oozie by apache.

the class LiteWorkflowAppParser method getGlobalFromString.

/**
 * Read the GlobalSectionData from Base64 string.
 * @param globalStr
 * @return GlobalSectionData
 * @throws WorkflowException
 */
private GlobalSectionData getGlobalFromString(String globalStr) throws WorkflowException {
    GlobalSectionData globalSectionData = new GlobalSectionData();
    try {
        byte[] data = Base64.decodeBase64(globalStr);
        Inflater inflater = new Inflater();
        DataInputStream ois = new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(data), inflater));
        globalSectionData.readFields(ois);
        ois.close();
    } catch (Exception ex) {
        throw new WorkflowException(ErrorCode.E0700, "Error while processing global section conf");
    }
    return globalSectionData;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InflaterInputStream(java.util.zip.InflaterInputStream) WorkflowException(org.apache.oozie.workflow.WorkflowException) Inflater(java.util.zip.Inflater) DataInputStream(java.io.DataInputStream) JDOMException(org.jdom.JDOMException) IOException(java.io.IOException) ParameterVerifierException(org.apache.oozie.util.ParameterVerifierException) WorkflowException(org.apache.oozie.workflow.WorkflowException) SAXException(org.xml.sax.SAXException)

Example 47 with InflaterInputStream

use of java.util.zip.InflaterInputStream in project h2database by h2database.

the class ArchiveTool method extract.

private static void extract(String fromFile, String toDir) throws IOException {
    Log log = new Log();
    long start = System.nanoTime();
    long startMs = System.currentTimeMillis();
    long size = new File(fromFile).length();
    log.println("Extracting " + size / MB + " MB at " + new java.sql.Time(startMs).toString());
    InputStream in = new BufferedInputStream(new FileInputStream(fromFile), 1024 * 1024);
    String temp = fromFile + ".temp";
    Inflater inflater = new Inflater();
    in = new InflaterInputStream(in, inflater, 1024 * 1024);
    OutputStream out = getDirectoryOutputStream(toDir);
    combine(log, in, out, temp);
    inflater.end();
    in.close();
    out.close();
    log.println();
    log.println("Extracted in " + TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start) + " seconds");
}
Also used : BufferedInputStream(java.io.BufferedInputStream) DataInputStream(java.io.DataInputStream) BufferedInputStream(java.io.BufferedInputStream) InflaterInputStream(java.util.zip.InflaterInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) InflaterInputStream(java.util.zip.InflaterInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DeflaterOutputStream(java.util.zip.DeflaterOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) DataOutputStream(java.io.DataOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) Inflater(java.util.zip.Inflater) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 48 with InflaterInputStream

use of java.util.zip.InflaterInputStream in project Discord4J by Discord4J.

the class DiscordWS method onWebSocketBinary.

@Override
public void onWebSocketBinary(byte[] payload, int offset, int len) {
    BufferedReader reader = new BufferedReader(new InputStreamReader(new InflaterInputStream(new ByteArrayInputStream(payload, offset, len))));
    onWebSocketText(reader.lines().collect(Collectors.joining()));
    try {
        reader.close();
    } catch (IOException e) {
        Discord4J.LOGGER.error(LogMarkers.WEBSOCKET, "Encountered websocket error: ", e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) InflaterInputStream(java.util.zip.InflaterInputStream) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException)

Example 49 with InflaterInputStream

use of java.util.zip.InflaterInputStream in project env-tool-suite by stormning.

the class Version2LicenseDecoder method unzipText.

private Reader unzipText(byte[] licenseText) {
    ByteArrayInputStream in = new ByteArrayInputStream(licenseText);
    in.skip((long) LICENSE_PREFIX.length);
    InflaterInputStream zipIn = new InflaterInputStream(in, new Inflater());
    try {
        return new InputStreamReader(zipIn, "UTF-8");
    } catch (UnsupportedEncodingException var5) {
        throw new LicenseException(var5);
    }
}
Also used : LicenseException(com.atlassian.extras.common.LicenseException) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) InflaterInputStream(java.util.zip.InflaterInputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Inflater(java.util.zip.Inflater)

Example 50 with InflaterInputStream

use of java.util.zip.InflaterInputStream in project bb4-common by bb4.

the class Base64Codec method decompress.

/**
 * Take a String and decompress it.
 * @param data the compressed string to decompress.
 * @return the decompressed string.
 */
public static synchronized String decompress(final String data) {
    // convert from string to bytes for decompressing
    byte[] compressedDat = Base64.decodeBase64(data.getBytes());
    final ByteArrayInputStream in = new ByteArrayInputStream(compressedDat);
    final Inflater inflater = new Inflater();
    final InflaterInputStream iStream = new InflaterInputStream(in, inflater);
    final char[] cBuffer = new char[4096];
    StringBuilder sBuf = new StringBuilder();
    try {
        InputStreamReader iReader = new InputStreamReader(iStream, CONVERTER_UTF8);
        while (true) {
            final int numRead = iReader.read(cBuffer);
            if (numRead == -1) {
                break;
            }
            sBuf.append(cBuffer, 0, numRead);
        }
    } catch (UnsupportedEncodingException e) {
        throw new IllegalArgumentException("Unsupported encoding exception :" + e.getMessage(), e);
    } catch (IOException e) {
        throw new IllegalStateException("io error :" + e.getMessage(), e);
    }
    return sBuf.toString();
}
Also used : InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) InflaterInputStream(java.util.zip.InflaterInputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Inflater(java.util.zip.Inflater) IOException(java.io.IOException)

Aggregations

InflaterInputStream (java.util.zip.InflaterInputStream)200 ByteArrayInputStream (java.io.ByteArrayInputStream)113 InputStream (java.io.InputStream)100 IOException (java.io.IOException)74 Inflater (java.util.zip.Inflater)66 ByteArrayOutputStream (java.io.ByteArrayOutputStream)50 GZIPInputStream (java.util.zip.GZIPInputStream)39 DataInputStream (java.io.DataInputStream)33 FileInputStream (java.io.FileInputStream)27 BufferedInputStream (java.io.BufferedInputStream)24 InputStreamReader (java.io.InputStreamReader)13 DeflaterOutputStream (java.util.zip.DeflaterOutputStream)13 HttpURLConnection (java.net.HttpURLConnection)12 URL (java.net.URL)11 File (java.io.File)10 BufferedReader (java.io.BufferedReader)9 OutputStream (java.io.OutputStream)9 Point (java.awt.Point)7 EOFException (java.io.EOFException)7 URLConnection (java.net.URLConnection)7