public class Demo02File {
public static void main(String[] args) throws IOException {
//append:true 续写
FileOutputStream fos = new FileOutputStream("C:\\Users\\43885\\Desktop\\黑马课件\\a.txt",true);
for (int i = 1; i <10 ; i++) {
//write 写出的是以二进制形式,需要用getBytes 将文字转成二进制
fos.write("你好".getBytes());
//换行 "\r\n"
fos.write("\r\n".getBytes());
}
}
}
输入流输出流续写换行
最新推荐文章于 2023-04-05 17:04:50 发布