Java by API/java.util.zip/GZIPInputStream — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 14:22, 31 мая 2010
GZIPInputStream: read(byte[] buf, int off, int len)
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.GZIPInputStream;
public class MainClass {
public static int sChunk = 8192;
public static void main(String[] args) throws Exception {
String zipname = "data.txt.gz";
String source = "data.txt.gz";
GZIPInputStream zipin;
FileInputStream in = new FileInputStream(zipname);
zipin = new GZIPInputStream(in);
byte[] buffer = new byte[sChunk];
// decompress the file
FileOutputStream out = new FileOutputStream(source);
int length;
while ((length = zipin.read(buffer, 0, sChunk)) != -1)
out.write(buffer, 0, length);
out.close();
zipin.close();
}
}
new GZIPInputStream(InputStream in)
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.GZIPInputStream;
public class MainClass {
public static int sChunk = 8192;
public static void main(String[] args) throws Exception {
String zipname = "data.txt.gz";
String source = "data.txt.gz";
GZIPInputStream zipin;
FileInputStream in = new FileInputStream(zipname);
zipin = new GZIPInputStream(in);
byte[] buffer = new byte[sChunk];
// decompress the file
FileOutputStream out = new FileOutputStream(source);
int length;
while ((length = zipin.read(buffer, 0, sChunk)) != -1)
out.write(buffer, 0, length);
out.close();
zipin.close();
}
}