BufferedOutputStream 和 FileOutputStream写入二进制字节
方法定义
public BufferedOutputStream(OutputStream out) {
示例
BufferedOutputStream writer = new BufferedOutputStream(new FileOutputStream("demo.txt"));
writer.write("hello world".getBytes());
writer.close();
PrintWriter写入文本字符
方法定义
public PrintWriter(String fileName) throws FileNotFoundException{}
示例
PrintWriter writer = new PrintWriter("demo.txt");
writer.write("hello world");
writer.close();
参考
java自学:java写入文件有哪几种方法
————————————————
版权声明:本文为CSDN博主「彭世瑜」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。