/*
* BufferedWriter特殊方法:
* public void newLine() throws IOException 新起一行 换行
*
* BufferedReader特殊方法:
* public String readLine() throws IOException 读取一行内容
*/
public class Demo04_BufferedMethod {
public static void main(String[] args) throws IOException {
// BufferedWriter bw = new BufferedWriter(new FileWriter("c.txt"));
//
// bw.write("我爱java");
// bw.newLine();
// bw.write("我爱IO");
// bw.newLine();
// bw.write("我爱同桌!");
// bw.newLine();
//
// bw.close();
BufferedReader br = new BufferedReader(new FileReader("c.txt"));
//定义变量,存储本次读取到的这行数据
String line;
while((line=br.readLine())!=null) {
System.out.println(line);
}
br.close();
}
}
|
|