- 文件的输出流和输入流的用法基本一致,可以通过查阅java的官网文档来查阅更多使用的方法
- 以下为输出流实例,当程序运行完毕之后,可以看到test.txt内容FileOutputStreamTest.java的内容一致
import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class FileOutputStreamTest { public static void main(String args[]){ try{ FileInputStream fileInputStreamTest = new FileInputStream("src//FileOutputStreamTest.java"); FileOutputStream fileOutputStream = new FileOutputStream("test.txt"); { byte [] bbuf = new byte[32]; int hasRead = 0; while ((hasRead = fileInputStreamTest.read(bbuf))>0){ fileOutputStream.write(bbuf, 0, hasRead); } } }catch (IOException e){ e.printStackTrace(); } } }
java输入输出(4)输出流
猜你喜欢
转载自blog.csdn.net/weixin_39452731/article/details/82081380
今日推荐
周排行