缓冲输出流写出数据的缓冲区问题

来源:互联网 发布:北京超图软件 编辑:程序博客网 时间:2024/05/21 09:10
public class BufferedOutputStream_flush {public static void main(String[] args) throws IOException {FileOutputStream fos=new FileOutputStream("fos.txt");     BufferedOutputStream bos=new BufferedOutputStream(fos);String str="让我再看你一遍,从南到北123132";byte[] data=str.getBytes();//转换字节数组bos.write(data);/* * void flush() * 一次性将缓冲区中的数据写出 */bos.flush();//提高及时性System.out.println("写出完毕");//bos.close();//里面有flush方法}}

原创粉丝点击