| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 417 人关注过本帖
标题:关于 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
快速回复:关于 fileInputStream 在内存中存放的问题
数据加载中...
 
   



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

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