• 实训——IO流


    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    public class filedemo{
    public static void main(String[] args) throws IOException{
    String str = "12345abcdef@#&*软件工程";
    File file = new File("data.txt");
    FileWriter fw = new FileWriter(file);
    BufferedWriter bw = new BufferedWriter(fw);
    bw.write("12345abcdef@#&*软件工程");
    bw.newLine(); 
    bw.write("请多指教。");
    bw.close(); 
    fw.close(); 
    }
    }
    
    import java.io.BufferedReader;
    
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    public class readfile {
    public static void main(String[] args) throws IOException
    {
    File file=new File("data.txt");
    FileReader fr = new FileReader(file);
    BufferedReader br=new BufferedReader(fr);
    String str;
    while ((str = br.readLine()) != null) 
    {
    System.out.println(str);
    }
    System.out.println("绝对路径:" + file.getAbsolutePath());
    br.close(); 
    fr.close(); 
    }
    }
  • 相关阅读:
    js bubbleSort
    关于“ ,”的迷
    移位
    emacs 一些很有用的快捷键
    input&output
    async&await
    用dbforge调试procedure
    开发中常用的工具
    用Firefox的debugger来调试JavaScript
    Hibernate映射关系配置
  • 原文地址:https://www.cnblogs.com/pamper/p/11122343.html
Copyright © 2020-2023  润新知