Per decomprimere il pacchetto del post precedente si usano le stesse classi di prima pero in input
private static String gunzip() {
String risp = "Ok";
try{
FileInputStream fileStream = new FileInputStream("tosend.gz");
CheckedInputStream checksum = new CheckedInputStream(fileStream, new Adler32());
GZIPInputStream zip = new GZIPInputStream(checksum);
FileOutputStream s = new FileOutputStream("prova2.txt");
int lunghezza;
byte[] buffer = new byte[1024];
while ((lunghezza = zip.read(buffer)) > 0)
s.write(buffer, 0, lunghezza);
zip.close();
s.close();
fileStream.close();
}catch(Exception e){
System.err.println(e);
risp = e.toString();
}
return risp;
}
private static String gunzip() {
String risp = "Ok";
try{
FileInputStream fileStream = new FileInputStream("tosend.gz");
CheckedInputStream checksum = new CheckedInputStream(fileStream, new Adler32());
GZIPInputStream zip = new GZIPInputStream(checksum);
FileOutputStream s = new FileOutputStream("prova2.txt");
int lunghezza;
byte[] buffer = new byte[1024];
while ((lunghezza = zip.read(buffer)) > 0)
s.write(buffer, 0, lunghezza);
zip.close();
s.close();
fileStream.close();
}catch(Exception e){
System.err.println(e);
risp = e.toString();
}
return risp;
}
Commenti
Posta un commento