ネットワーク ドライブにファイルを作成し、そこにデータを追加しています。そのファイルへの書き込みに時々失敗します。データを保存するたびにファイルにアクセスできるかどうかを確認する良い方法はありますか、それともデータが保存されたかどうかを確認する方法はありますか?
編集:現在、コードで PrintStream を使用して try-catch ブロックを使用しています:
try
{
logfile = new File(new File(isic_log), "log_" + production);
//nasty workaround - we'll have a file the moment we assign an output stream to it
if (!logfile.exists())
{
prodrow = production;
}
out = new FileOutputStream(logfile.getPath(), logfile.exists());
p = new PrintStream(out);
if (prodrow != "")
{
p.println (prodrow);
}
p.println (chip_code + ":" + isic_number);
p.close();
}
catch (Exception e)
{
logger.info("Got exception while writing to isic production log: " + e.getMessage());
}
それで、PrintStreamが問題になるのでしょうか? ( PrintWriter と PrintStream は決して IOExceptions をスローしません)