/*
为什么BufferedOutputStream 中的 write()需要刷新缓冲区?
但BufferedInputStream 中的 read() 却不需要刷新缓冲区?
*/import java.io.*;public class BufferedStreamTest3
{
public static void main(String[] args) throws Exception
{
FileOutputStream fou = new FileOutputStream("c:\\temp\\1\\2\\haobin.txt");
BufferedOutputStream bou = new BufferedOutputStream(fou);

bou.write("同志们好!\n我代表党和人民感谢你!".getBytes()); //上机发现 必须刷新缓冲区或关闭流,否则不会立即把“同志们好!\n我代表党和人民感谢你! ”写入文件
bou.flush();
bou.close(); FileInputStream fin = new FileInputStream("c:\\temp\\1\\2\\haobin.txt");
BufferedInputStream bin = new BufferedInputStream(fin);
byte[] buf = new byte[100];
int len = bin.read(buf);  // 上机发现,读取时,不需要立即刷新缓冲区或关闭流,就可以把内容直接输出到buf数组中,read和write为什么不一致啊? 请诸位指教
System.out.print("haobin.txt文件中的内容是:\n");
System.out.println(new String(buf, 0, len));
//bin.close();
}}