/**
*
* 向文件指定位置写数据
*
* @param skipBytes
* 指定位置
* @author zhoobt
*
*/
public static boolean writeData(File file, long skipBytes, byte[] data) {
boolean result = false;
try {
RandomAccessFile rFile;
if (file.exists()) {
rFile = new RandomAccessFile(file, "rw");
rFile.seek(skipBytes);
byte[] otherdata = new byte[(int) (file.length() - skipBytes)];
rFile.read(otherdata);
rFile = new RandomAccessFile(file, "rw");
rFile.seek(skipBytes);
rFile.write(data);
rFile = new RandomAccessFile(file, "rw");
rFile.seek(data.length + skipBytes);
rFile.write(otherdata);
rFile.close();
rFile = null;
result = true;
}
} catch (Exception e) {
}
return result;
}
android向文件指定位置写数据
最新推荐文章于 2021-05-29 14:37:36 发布