zoukankan      html  css  js  c++  java
  • Java,文件读写demo

            File file = new File("C:/huhuhu.txt");
            FileInputStream in = new FileInputStream(file);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            String line = null;
            line = br.readLine();
            int i=1;
            String header = "rcvNotify -i ";
           
            File file2 = new File("C:/output.txt");
            FileWriter out = new FileWriter(file2);
           
           
           
            while ((line) != null && !line.equals("-----")) {
                header += line + ",";
               
                if(i%100==0){
                    header = header.substring(0, header.length()-1);
                    out.write(header);
                    header = "\r\nrcvNotify -i ";
                }
               
                System.out.println(i);
                i++;
                line = br.readLine();
            }
           
           
           
            in.close();
            out.close();

    ===============================

    String path = "C:/home/logs";
    String name = "a.txt";
    File file = new File(path, name);
    System.out.println(file.getParentFile().getName());
    file.getParentFile().mkdir();
    file.createNewFile();

  • 相关阅读:
    软件设计中的立足点
    Clojure基础
    团队凝聚力
    执行力与领导力
    工作与生活
    分离焦虑OR责任焦虑
    保持激情
    立足点
    论研发管理--开篇
    初级码农常犯错误
  • 原文地址:https://www.cnblogs.com/alipayhutu/p/2511912.html
Copyright © 2011-2022 走看看