import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class BufferedOutputStreamDemo
{
public static void main(String[] args)
{
File file = new File("d:\\a\\a.txt");
//获取文件路径;
if(!file.exists())
{
try
{
file.createNewFile(); //文件不存在就创建;
} catch (IOException e)
{
e.printStackTrace();
}
}
BufferedOutputStream bos = null; //字节输出流;
try
{
bos = new BufferedOutputStream(new FileOutputStream(file));
StringBuffer sb = new StringBuffer();
for(int i=0; i<100; i++)
{
sb.append(i).append("\t");
}
bos.write(sb.toString().getBytes()); //写入内容;
bos.flush(); //将缓冲区中的内容全部写出到目标文件;
bos.close();
//关闭流;
} catch (Exception e)
{
e.printStackTrace();
}
}
}