您的位置:首页 > 编程语言 > Java开发

JAVASE02-Unit07: 基本IO操作 、 文本数据IO操作

2016-12-31 19:58 489 查看

    基本IO操作 、 文本数据IO操作    

java标准IO(input/output)操作

package day07;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
* 缓冲流写出数据的缓冲区问题
* @author adminitartor
*
*/
public class Bos_Write {
public static void main(String[] args) throws IOException {
FileOutputStream fos
= new FileOutputStream("bos.txt");
BufferedOutputStream bos
= new BufferedOutputStream(fos);

String str = "i have a pen,i have a apple";

bos.write(str.getBytes());
/*
* void flush()
* 该方法可以强制将当前缓冲流中缓冲区中
* 的数据写出。
*/
bos.flush();

System.out.println("写出完毕!");

bos.close();
}
}


Bos_Write.java
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: