关于文件输出流
构造器

方法一览

示例代码
import java.io.FileOutputStream;import java.io.IOException;public class Main { public static void main(String[] args) { // 文件路径 String path = "./write.txt"; // true=追加、false=覆盖 boolean append = true; FileOutputStream fos = null; try { // 创建流对象 fos = new FileOutputStream(path,append); String str = "0123456789ABCDEFG\n"; // 将 String 转换为 Byte 数组后,使用流对象写入文件 fos.write(str.getBytes()); fos.write(str.getBytes(), 0, str.length()); fos.write(str.getBytes(), 0, 3); } catch (IOException e) { e.printStackTrace(); } finally { // 关闭连接 try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } }}