在操作文件上传下传的时候用到了文件的复制工作,特记录一下。
try (RandomAccessFile raf_write = new RandomAccessFile(tempMergeFile, "rw");) {
byte[] b = new byte[1024];
for (File file : files) {
RandomAccessFile raf_read = new RandomAccessFile(file, "r");
int len = -1;
while ((len = raf_read.read(b)) != -1) {
raf_write.write(b,0,len);
}
}catch (IOException e) {
throw new RuntimeException(e);
}
将file中的数据写入到raf_write中.