• java 读取Zip文件进行写入


    直接读取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");
        }
      }
    
    }
  • 相关阅读:
    iOS 10 的杂碎资料
    MAC SVN Merge 操作
    iOS中AFNetworking2.0和AFNetworking3.0 的HTTPS的配置
    从字符串中获取指定字符内的内容
    判断是否是是全汉字、全字母、全数字、数字和字母等
    解析URL 获取某一个参数值
    长按TextField或TextView显示中文的粘贴复制
    TextField和TextView的限制输入长度
    抢购、距活动结束,剩余时间倒计时。
    Cell右滑 多个编辑选项栏
  • 原文地址:https://www.cnblogs.com/sunxun/p/6700180.html
Copyright © 2020-2023  润新知