IO 流理解实例
import java.io.* ;
import java.util.Scanner ;
public class TestBuffered {
public static void main(String[] args) {
Scanner sca = new Scanner(System.in);
try{
BufferedWriter bw = new BufferedWriter(new FileWriter("d:/LX/t.txt"));
BufferedReader br = new BufferedReader(new FileReader("d:/LX/t.txt"));
String s = "" ;
//s = sca.nextLine();
while(!s.equals("N")) {
System.out.println("请输入数据:");
s = sca.nextLine();
bw.write(s);
bw.newLine();
}
bw.flush();
while((s=br.readLine()) != null){
System.out.println(s);
}
bw.close();
br.close();
}catch(IOException ex){
ex.printStackTrace();
}
}
}