package split;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.RandomAccessFile;
public class Split {
public static String file_path = "D:\\学习\\实验室项目\\ImageNet图片爬取\\fall11_urls.txt";
public static String file_path_1 = "D:\\学习\\实验室项目\\ImageNet图片爬取\\split\\1.txt";
static long originFileSize = 1024 * 1024 * 100;// 100M
static int blockFileSize = 1024 * 1024 * 1;// 15M
public static void main(String[] args) {
// TODO Auto-generated method stub
split();
}
public static void split(){
RandomAccessFile rFile;
OutputStream os;
try {
rFile = new RandomAccessFile(file_path, "r");
int count = (int) Math.ceil(rFile.length() / (double) blockFileSize);
byte[] b = new byte[1000];
rFile.seek(count);// 移动指针到每“段”开头
int s = rFile.read(b);
os = new FileOutputStream(file_path_1);
os.write(b, 0, s);
os.flush();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
java 随机读取数据流 java 随机读取文件
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章