关于 fileInputStream 在内存中存放的问题
public class Downloads {private static FileInputStream fileInput;
public static void main(String[] args) throws Exception{
String sourcePate = "D:/new/1.txt";
String restPate1 = "D:/new/1(1).txt";
String restPate2 = "D:/new/1(2).txt";
String restPate3 = "D:/new/1(3).txt";
File file = new File(sourcePate);
int len = (int)file.length();
byte[] buffer = new byte[len];
if(len%3==0){
int newLen=len/3;
fileInput = new FileInputStream(sourcePate);
fileInput.read(buffer, 0, newLen);
FileOutputStream fileOutput1 = new FileOutputStream(restPate1);
fileOutput1.write(buffer, 0, newLen);
fileInput.read(buffer, 0, newLen);
FileOutputStream fileOutput2 = new FileOutputStream(restPate2);
fileOutput2.write(buffer, 0, newLen);
fileInput.read(buffer, 0, newLen);
FileOutputStream fileOutput3 = new FileOutputStream(restPate3);
fileOutput3.write(buffer, 0, newLen);
}
}
}
我在文件1.txt中放入123456789,读出来的三个文件1(1).txt,1(2).txt,1(3).txt为什么分别是123,456,789而不是123,123,123;