java io使用字符流读写文件

 

BufferedReader br = new BufferedReader(new FileReader("data.txt");
String s = null;
while((s = br.readLine()) != null){
  System.out.println(s);
}

 

PrintWriter pw = new PrintWriter(new FileWriter("data.txt"));
pw.write("helloworld");
pw.close();

 

你可能感兴趣的:(java,IO)