BufferStream

//数据缓冲流,经常用来套在其它流上面,提高读取和写入的效率
import java.io.*;
public class TestBufferStream {
public static void main(String[] args) {
try {
BufferedWriter bw = new BufferedWriter(new FileWriter("F:\\javashipin\\test.txt"));
BufferedReader br = new BufferedReader(new FileReader("F:\\javashipin\\test.txt"));
String s = null;
//把100个随机数写入文件test.txt中
for(int i=1;i<=100;i++){
s = String.valueOf(Math.random());
bw.write(s);
bw.newLine();
}
bw.flush();
//再从test.txt文件中读取数据
while((s=br.readLine())!=null){
System.out.println(s);
}
bw.close(); 
br.close();
} catch (IOException e) 
{ 
e.printStackTrace();
}
}
}

 

你可能感兴趣的:(F#)