首页 > 其他 > 详细

文件字符流

时间:2019-11-10 15:56:45      阅读:86      评论:0      收藏:0      [点我收藏+]

package com.study02;

import java.io.FileWriter;
import java.io.IOException;

public class fileWrite {
public static void main(String[] args) {
//创建对象
FileWriter writer= null;
try {
writer = new FileWriter("ccc.txt");


//写数据
writer.write("hello");//写到了缓冲区

//手动刷新缓冲
writer.flush();

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
//关闭,添加了手动刷新缓冲可不写close
if (writer!=null) {
try {
writer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}

}
}

文件字符流

原文:https://www.cnblogs.com/LuJunlong/p/11830337.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!