本文整理汇总了Java中java.util.zip.Deflater.BEST_COMPRESSION属性的典型用法代码示例。如果您正苦于以下问题:Java Deflater.BEST_COMPRESSION属性的具体用法?Java Deflater.BEST_COMPRESSION怎么用?Java Deflater.BEST_COMPRESSION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.zip.Deflater
的用法示例。
在下文中一共展示了Deflater.BEST_COMPRESSION属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dumpFlate
/** Write the entire content into the given file using Flate compression (see RFC1951) then return the number of bytes written. */
public long dumpFlate(RandomAccessFile os) throws IOException {
Deflater zip = new Deflater(Deflater.BEST_COMPRESSION);
byte[] output = new byte[8192];
Iterator<byte[]> it = list.iterator(); // when null, that means we have told the Deflater that no more input would be coming
long ans = 0; // the number of bytes written out so far
while(true) {
if (it!=null && zip.needsInput() && it.hasNext()) {
byte[] in = it.next();
if (in == list.getLast()) { zip.setInput(in, 0, n); it=null; zip.finish(); } else { zip.setInput(in, 0, SIZE); }
}
if (it==null && zip.finished()) break;
int count = zip.deflate(output);
if (count > 0) {
ans = ans + count;
if (ans < 0) throw new IOException("Data too large to be written to the output file.");
os.write(output, 0, count);
}
}
return ans;
}
示例2: getZipCompressionLevel
private int getZipCompressionLevel(FuzzyCompressionLevel compressionLevel) {
switch (compressionLevel) {
case BEST:
return Deflater.BEST_COMPRESSION;
case FASTEST:
return Deflater.BEST_SPEED;
case NONE:
return Deflater.NO_COMPRESSION;
case DEFAULT:
default:
return Deflater.DEFAULT_COMPRESSION;
}
}
示例3: ZioEntryOutputStream
public ZioEntryOutputStream( int compression, OutputStream wrapped)
{
this.wrapped = wrapped;
if (compression != 0)
downstream = new DeflaterOutputStream( wrapped, new Deflater( Deflater.BEST_COMPRESSION, true));
else downstream = wrapped;
}
示例4: dumpFlate
/**
* Write the entire content into the given file using Flate compression (see
* RFC1951) then return the number of bytes written.
*/
public long dumpFlate(RandomAccessFile os) throws IOException {
Deflater zip = new Deflater(Deflater.BEST_COMPRESSION);
byte[] output = new byte[8192];
Iterator<byte[]> it = list.iterator(); // when null, that means we have
// told the Deflater that no
// more input would be coming
long ans = 0; // the number of bytes written out so far
while (true) {
if (it != null && zip.needsInput() && it.hasNext()) {
byte[] in = it.next();
if (in == list.getLast()) {
zip.setInput(in, 0, n);
it = null;
zip.finish();
} else {
zip.setInput(in, 0, SIZE);
}
}
if (it == null && zip.finished())
break;
int count = zip.deflate(output);
if (count > 0) {
ans = ans + count;
if (ans < 0)
throw new IOException("Data too large to be written to the output file.");
os.write(output, 0, count);
}
}
return ans;
}
示例5: writeZTXT
private void writeZTXT() throws IOException
{
if (param.isCompressedTextSet())
{
String[] text = param.getCompressedText();
for (int i = 0; i < text.length / 2; i++)
{
byte[] keyword = text[2 * i].getBytes();
byte[] value = text[2 * i + 1].getBytes();
ChunkStream cs = new ChunkStream("zTXt");
cs.write(keyword, 0, Math.min(keyword.length, 79));
cs.write(0);
cs.write(0);
DeflaterOutputStream dos = new DeflaterOutputStream(cs,
new Deflater(Deflater.BEST_COMPRESSION, true));
dos.write(value);
dos.finish();
cs.writeToStream(dataOutput);
cs.close();
}
}
}
示例6: serialise
@Override
public JSONObject serialise() {
JSONObject json = new JSONObject();
byte[] terrain = new byte[width * width];
for (int x = 0; x < World.WORLD_SIZE; x++) {
for (int y = 0; y < World.WORLD_SIZE; y++) {
terrain[x * width + y] = (byte) tiles[x][y];
}
}
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Deflater compressor = new Deflater(Deflater.BEST_COMPRESSION, true);
DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(stream, compressor);
deflaterOutputStream.write(terrain);
deflaterOutputStream.close();
byte[] compressedBytes = stream.toByteArray();
json.put("z", new String(Base64.getEncoder().encode(compressedBytes)));
} catch (IOException e) {
e.printStackTrace();
}
return json;
}
示例7: setLevel0
private void setLevel0(int level) {
if ((level < Deflater.NO_COMPRESSION || Deflater.BEST_COMPRESSION < level)
&& level != Deflater.DEFAULT_COMPRESSION)
throw new IllegalArgumentException("Invalid compression level!");
this.level = level;
}
示例8: ZMBVVideoCodec
public ZMBVVideoCodec(int height, Font terminalFont, Object object,
boolean allowBold) {
super(height, terminalFont, object, allowBold);
deflater = new Deflater(Deflater.BEST_COMPRESSION);
}
示例9: getLevel
/**
* Returns the compression level to use when writing a GZIP sink stream.
* <p>
* The implementation in the class {@link TarGZipDriver} returns
* {@link Deflater#BEST_COMPRESSION}.
*
* @return The compression level to use when writing a GZIP sink stream.
*/
public int getLevel() {
return Deflater.BEST_COMPRESSION;
}
示例10: getLevel
/**
* {@inheritDoc}
* <p>
* The implementation in the class {@link ZipDriver}
* returns {@code Deflater#BEST_COMPRESSION}.
*
* @return {@code Deflater#BEST_COMPRESSION}
*/
@Override
public int getLevel() {
return Deflater.BEST_COMPRESSION;
}