指定したフォルダーにバイナリ ファイルを書き込もうとしていますが、例外が発生し続けます。たとえば、フォルダーを指定せずにファイルを書き込むと、プログラムは問題なく書き込みます。
public void saveFile(String name) throws IOException {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(name + ".bin"));
out.writeObject(this);
out.close();
}
ただし、フォルダーを指定しようとすると、プログラムはファイルを書き込みません。
public void saveFile(String name) throws IOException {
File location = new File("/path/" + name + ".bin");
FileOutputStream fos = new FileOutputStream(location);
ObjectOutputStream out = new ObjectOutputStream(fos);
out.writeObject(this);
out.close();
fos.close();
}
私はいくつかの異なる方法を試しましたが、まだ解決策はありません。誰かが私が間違っていることを知っていますか?