/*
* 缓冲流读取文件或者写入文件都需要用缓存技术 ,其中有读取文本行的办法 readLine(),还有写入回行符的办法 newLine()
*/
package Practice;
import java.io.*;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
File file = new File("Student.txt");
String content[] = {"11111","22222","33333","44444"};
try {
FileWriter outone = new FileWriter(file);
BufferedWriter outtwo = new BufferedWriter(outone);
for(String str:content) {
outtwo.write(str);
outtwo.newLine(); //写入回行符
}
outtwo.close();
outone.close();
FileReader inone = new FileReader(file);
BufferedReader intwo = new BufferedReader(inone);
String s = null;
while((s = intwo.readLine()) != null) {
System.out.println(s);
}
inone.close();
intwo.close();
}
catch(IOException e){
System.out.println(e);
}
}
}