在写入模式下打开文件时出错

时间:2013-03-05 08:56:40

标签: java file-io io

我试着写一个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();
        }
    }
}

0 个答案:

没有答案