问题遇到的现象和发生背景
文件正确复制了,但是还是会报越界异常。不知道为什么。
问题相关代码,请勿粘贴截图
import java.io.*;
public class Test03 {
public static void main(String[] args) throws Exception {
copy1();
}
public static void copy1() throws Exception {
File f1 = new File("C:\\LeanningFiles\\Test1\\鞠婧祎.jpg");
File f2 = new File("C:\\LeanningFiles\\yi\\小.jpg");
FileInputStream fis = new FileInputStream(f1);
FileOutputStream fos = new FileOutputStream(f2);
byte[] b = new byte[1024];
int len;
while ((len = fis.read(b)) != 0) {
fos.write(b, 0, len);
}
fis.close();
fos.close();
}
}