JDK原生支持读取GZ文件,使用的方法如下:
String fileName=directoryHeader+group;
//使用GZIPInputStream解压GZ文件
InputStream in = new GZIPInputStream(new FileInputStream(fileName));
Scanner sc=new Scanner(in);
List<String> lines=new ArrayList();
while(sc.hasNextLine()){
lines.add(sc.nextLine());
}
System.out.println(lines.toString());