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;
}
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");
}
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);
}
}
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);
}
}
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();
}
Aggregations