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();
}
}
}