直接读取ZIp文件读取写入到别的文件中。
package jp.co.misumi.mdm.batch; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.zip.GZIPInputStream; public class MainSample { public static void main(String[] args) { long start = System.currentTimeMillis(); FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream("D:/Misumi MDM/WorkSpace/mdmtsv/update_log_17631.tsv.gz"); GZIPInputStream gzis = new GZIPInputStream(fis); InputStreamReader reader = new InputStreamReader(gzis); BufferedReader in = new BufferedReader(reader); fos = new FileOutputStream("D:/Misumi MDM/WorkSpace/mdmtsv/update_log_17631.tsv"); String line = null; while ((line = in.readLine()) != null) { // System.out.println(readed); String[] datas = line.split(" ", -1); if("m_product".equals(datas[2].toLowerCase())) { fos.write(line.getBytes()); fos.write(" ".getBytes()); } } in.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (fis != null) { try { fis.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (fos != null) { try { fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } long end = System.currentTimeMillis(); System.out.println("Total run Time is :" + (end - start) + "ms"); } } }