标题:关于 fileInputStream 在内存中存放的问题
只看楼主
伪为君子
Rank: 2
等 级:论坛游民
帖 子:2
专家分:10
注 册:2014-10-27
 问题点数:0 回复次数:0 
关于 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;
搜索更多相关主题的帖子: private public file 
2014-10-27 10:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-437749-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.274399 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved