概述
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));
}
}
}
文件复制
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基础补漏--文件读取所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复