use of java.util.zip.DeflaterOutputStream in project intellij-community by JetBrains.
the class SourceCodeCompressor method compress.
public static synchronized byte[] compress(byte[] source, int off, int len) {
try {
DEFLATER.reset();
DEFLATER.setDictionary(PRESET_BUF);
try {
DeflaterOutputStream output = null;
try {
output = new DeflaterOutputStream(OUTPUT, DEFLATER);
output.write(source, off, len);
} finally {
if (output != null) {
output.close();
}
}
} catch (IOException e) {
return source;
}
return OUTPUT.toByteArray();
} finally {
OUTPUT.reset();
}
}
use of java.util.zip.DeflaterOutputStream in project intellij-community by JetBrains.
the class ConnectionStreams method setGzipped.
// Actions ================================================================
// Actions ================================================================
public void setGzipped() throws IOException {
loggedWriter.flush();
loggedOutputStream.flush();
deflaterOutputStream = new DeflaterOutputStream(connection.getOutputStream(), new Deflater(6));
setOutputStream(deflaterOutputStream);
setInputStream(new InflaterInputStream(connection.getInputStream()));
}
use of java.util.zip.DeflaterOutputStream in project gerrit by GerritCodeReview.
the class PatchList method writeObject.
private void writeObject(final ObjectOutputStream output) throws IOException {
final ByteArrayOutputStream buf = new ByteArrayOutputStream();
try (DeflaterOutputStream out = new DeflaterOutputStream(buf)) {
writeCanBeNull(out, oldId);
writeNotNull(out, newId);
writeVarInt32(out, isMerge ? 1 : 0);
comparisonType.writeTo(out);
writeVarInt32(out, insertions);
writeVarInt32(out, deletions);
writeVarInt32(out, patches.length);
for (PatchListEntry p : patches) {
p.writeTo(out);
}
}
writeBytes(output, buf.toByteArray());
}
use of java.util.zip.DeflaterOutputStream in project poi by apache.
the class Metafile method compress.
protected static byte[] compress(byte[] bytes, int offset, int length) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DeflaterOutputStream deflater = new DeflaterOutputStream(out);
deflater.write(bytes, offset, length);
deflater.close();
return out.toByteArray();
}
use of java.util.zip.DeflaterOutputStream in project teaTime by ancfdy.
the class AppZLibMgr method compress.
/**
* 压缩
*
* @param data
* 待压
*缩数据
* @param os
* 输出流
*/
public static void compress(byte[] data, OutputStream os) {
DeflaterOutputStream dos = new DeflaterOutputStream(os);
try {
dos.write(data, 0, data.length);
dos.finish();
dos.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations