RandomAccessFile rf=new RandomAccessFile("c:\\a.jpg","rw");
// 定位读取的位置
rf.seek(1230);
System.out.println(rf.length());
RandomAccessFile currentPart = new RandomAccessFile("c:\\www.jpg", "rw");
// 定位写入的位置
currentPart.seek(1230);
byte[] buffer = new byte[1024];
int hasRead = 0;
while ( (hasRead = rf.read(buffer)) != -1)
{
currentPart.write(buffer, 0, hasRead);
}
currentPart.close();
// 定位读取的位置
rf.seek(1230);
System.out.println(rf.length());
RandomAccessFile currentPart = new RandomAccessFile("c:\\www.jpg", "rw");
// 定位写入的位置
currentPart.seek(1230);
byte[] buffer = new byte[1024];
int hasRead = 0;
while ( (hasRead = rf.read(buffer)) != -1)
{
currentPart.write(buffer, 0, hasRead);
}
currentPart.close();