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基础补漏--文件读取内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复