本帖最后由 何竹冬 于 2013-1-6 13:40 编辑
- package cn.itcast.javabase;
- import java.io.*;
- /*
- 没有flush没有close,查看1.txt文件大小是10kb,写入成功。
- */
- public class Test
- {
- public static void main(String[] args) throws Exception
- {
- OutputStream out = new FileOutputStream("c:\\1.txt");
- byte[] buf = new byte[1024*10];
- BufferedOutputStream buffOut=new BufferedOutputStream(out);
- buffOut.write(buf);
- }
- }
复制代码- package cn.itcast.javabase;
- import java.io.*;
- /*
- 没有flush没有close,发现1.txt0kb,写入失败
- */
- public class Test
- {
- public static void main(String[] args) throws Exception
- {
- OutputStream out = new FileOutputStream("c:\\1.txt");
- byte[] buf = new byte[1024*5];
- BufferedOutputStream buffOut=new BufferedOutputStream(out);
- buffOut.write(buf);
- }
- }
复制代码 |