为啥第一个程序可以全部输出图片,第二个却只能输出一部分,只有扩大第二个数组第二个才能输出全部图片,另外第一个不是应该输出实际输入字节,但录入的应该只有1024啊,希望有人帮帮我以下是源码
package liu;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class tupianzhuanyi {
public static void main(String[] args) throws IOException {
FileInputStream q = new FileInputStream("C:\Users\xuan\Pictures\VRChat\2022-02\oi.png");
FileOutputStream w = new FileOutputStream("D:\yy\oi.png");
byte[] b = new byte[1024];
int ln;
while ((ln = q.read(b)) != -1) {
w.write(b,0,ln);
}
q.close();
w.close();
}
}
第二个程序
package liu;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class demo {
public static void main(String[] args) throws IOException {
FileInputStream q = new FileInputStream("C:\Users\xuan\Pictures\VRChat\2022-02\oi.png");
FileOutputStream w = new FileOutputStream("D:\yy\oi.png");
byte[] b = new byte[1024];
int ln = q.read(b);
w.write(b);
q.close();
w.close();
}
}