Java by API/java.util.zip/Inflater — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 14:22, 31 мая 2010
Inflater: inflate(byte[] b)
import java.io.ByteArrayOutputStream;
import java.util.zip.Inflater;
public class Main {
public static void main(String[] argv) throws Exception {
byte[] compressedData = null;
Inflater decompressor = new Inflater();
decompressor.setInput(compressedData);
ByteArrayOutputStream bos = new ByteArrayOutputStream(compressedData.length);
byte[] buf = new byte[1024];
while (!decompressor.finished()) {
int count = decompressor.inflate(buf);
bos.write(buf, 0, count);
}
bos.close();
byte[] decompressedData = bos.toByteArray();
}
}
Inflater: setInput(byte[] b)
import java.io.ByteArrayOutputStream;
import java.util.zip.Inflater;
public class Main {
public static void main(String[] argv) throws Exception {
byte[] compressedData = null;
Inflater decompressor = new Inflater();
decompressor.setInput(compressedData);
ByteArrayOutputStream bos = new ByteArrayOutputStream(compressedData.length);
byte[] buf = new byte[1024];
while (!decompressor.finished()) {
int count = decompressor.inflate(buf);
bos.write(buf, 0, count);
}
bos.close();
byte[] decompressedData = bos.toByteArray();
}
}
new Inflater()
import java.io.ByteArrayOutputStream;
import java.util.zip.Inflater;
public class Main {
public static void main(String[] argv) throws Exception {
byte[] compressedData = null;
Inflater decompressor = new Inflater();
decompressor.setInput(compressedData);
ByteArrayOutputStream bos = new ByteArrayOutputStream(compressedData.length);
byte[] buf = new byte[1024];
while (!decompressor.finished()) {
int count = decompressor.inflate(buf);
bos.write(buf, 0, count);
}
bos.close();
byte[] decompressedData = bos.toByteArray();
}
}