package zuoye; import java.io.*; import java.io.File; public class io { public static void main(String[] args) { String red="12345abcdef@#%&*软件工程"; File file=new File("D:\\data.txt"); try { FileWriter fw=new FileWriter(file); BufferedWriter bw=new BufferedWriter(fw); bw.write(red); bw.newLine(); bw.close(); fw.close(); }catch(Exception e){ e.printStackTrace(); } try { FileReader fr=new FileReader(file); BufferedReader bf=new BufferedReader(fr); String str1=null; while((str1=bf.readLine())!=null) { System.out.print(str1); } bf.close(); fr.close(); }catch(Exception e) { e.printStackTrace(); } } }
转载于:https://www.cnblogs.com/YM4396/p/11141775.html