1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| public NFichier extraireGZ(File fic) throws NFichierException {
NFichier fichier = new NFichier("c:/extractgz");
try {
GZIPInputStream zipin;
try {
FileInputStream in = new FileInputStream(fic);
zipin = new GZIPInputStream(in);
}
catch (IOException e) {
System.out.println("Couldn't open " + fic + ".");
return null;
}
BufferedOutputStream outFichier =new BufferedOutputStream(new FileOutputStream(fichier));
byte octet[] = new byte[32];
int offset = 0;
int num;
while ((num = zipin.read(octet, offset, 32)) != -1) {
outFichier.write(octet, offset, num);
}
outFichier.close();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return fichier;
} |