• 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();

  • 相关阅读:
    iBatis,第二次亲密接触
    微斯人,吾谁与归
    一个月了
    生命在于运动
    眼皮跳了好几天
    往返
    中病毒,学习批处理

    爱如潮水
    今天夏至
  • 原文地址:https://www.cnblogs.com/alipayhutu/p/2511912.html
Copyright © 2020-2023  润新知