我是靠谱客的博主 酷炫外套,这篇文章主要介绍JAVA基础补漏--文件读取,现在分享给大家,希望可以做个参考。

639458-20190306101100921-58624035.png

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public class Test2 { public static void main(String[] args) throws IOException { FileInputStream fis = new FileInputStream("1.txt"); int len = 0; byte[] bytes = new byte[200]; while ((len = fis.read(bytes)) != -1) { System.out.println(len); System.out.println(new String(bytes,0,len)); } } }

文件复制

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public class Test2 { public static void main(String[] args) throws IOException { FileInputStream fis = new FileInputStream("C:\sdcs\1.png"); FileOutputStream fos = new FileOutputStream("D:\sdcs\1.png"); int len = 0; byte[] bytes = new byte[1024]; while ((len = fis.read(bytes)) != -1) { fos.write(bytes,0,len); } fos.close(); fis.close(); } }

转载于:https://www.cnblogs.com/comeluder/p/10481562.html

最后

以上就是酷炫外套最近收集整理的关于JAVA基础补漏--文件读取的全部内容,更多相关JAVA基础补漏--文件读取内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部