我尝试编写一个 hexeditor 作为练习,但我发现我的程序在尝试以写入模式打开文件时总是返回错误。这是我的程序部分:
try {
byte[] buffer={(byte) 0xfe, (byte) 0xfe};
out = openFileOutput(filename.toString(), 0);
out.write(buffer, 0x50, 2);
out.write(buffer, 0x5c, 2);
out.write(buffer, 0x64, 2);
out.write(buffer, 0x290, 2);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}