BufferedWriter
public class demo15 {
//字符缓冲流的特有功能newLine
public static void main(String[] args) throws IOException {
BufferedWriter bufferedWriter=new BufferedWriter(new FileWriter("D:\\itcast\\myjava.txt"));
for (int i = 0; i <10 ; i++) {
bufferedWriter.write("hello"+i);
bufferedWriter.newLine();
bufferedWriter.flush();
}
bufferedWriter.close();
}
}
BufferedReader
BufferedReader bufferedReader=new BufferedReader(new FileReader("D:\\itcast\\myjava.txt"));
String s;
while ((s=bufferedReader.readLine())!=null){
System.out.println(s);
}