public static String uncompressGzip(String filePath,String ext) throws IOException{
InputStream input = new FileInputStream(filePath);
GZIPInputStream is = new GZIPInputStream(input);
byte [] buffer = new byte[1024] ;
int count = 0;
String newFilePath = filePath.replace("gzip",ext);
OutputStream os = new FileOutputStream(newFilePath);
while ( (count = is.read(buffer)) != -1){
os.write(buffer,0,count);
}
os.flush();
os.close();
is.close();
input.close();
return newFilePath;
}
这里主要使用GZIPInputStream流。