package SecondTermUp;
import java.*;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
public class Fifth{
public void BufferIOStream() {
String content[] = {"好久不见","最近好么","常联系"};
File file = new File("D:\\JAVA\\Javahomework\\Test/Fifth.txt");
try {
FileWriter fw = new FileWriter(file);
BufferedWriter bufw = new BufferedWriter(fw);
for(String con : content) {
bufw.write(con);
bufw.newLine();
}
bufw.close();
fw.close();
}
catch(Exception e) {
e.printStackTrace();
}
try {
FileReader fr = new FileReader(file);
BufferedReader bufr = new BufferedReader(fr);
String s = null;
int i = 0;
while((s = bufr.readLine()) != null) {
i++;
System.out.println("第" + i + "行:" + s);
}
bufr.close();
fr.close();
}
catch(Exception e) {
e.printStackTrace();
}
}
}