文件字节输出流(写入内容)

public static void testFileWriter(String text, String outPath) {
try {
FileWriter fw = new FileWriter(outPath);
//将字符串写到内存中
fw.write(text);
//将内存中的数据刷到硬盘
fw.flush();
fw.close();
} catch (Exception e) {
e.printStackTrace();
}
}

文件字节输出流(写入文件内容)
创建字符输出流的对象,用trycatch捕获异常
将要写的内容存到内容中
将内存中的数据刷写到硬盘中
关闭流

posted @ 2022-03-15 16:56  SmallPepsi  阅读(66)  评论(0)    收藏  举报