RandomAccessFile randomAccessFile = null;
randomAccessFile = new RandomAccessFile(file, "rw");
byte buf[] = new byte[1024];
int len = -1;
while ((len = in.read(buf)) > -1) {
/* randomAccessFile.write(buf);
此处相当于randomAccessFile(buf,0,1024);
如果实际每次没有读入1024个字节,将多写入多余的字节,造成文件拷贝不准确
*/
randomAccessFile.write(buf,0,len);
}
randomAccessFile.close();