PrintWriter doesn't throw exceptions, so call checkError()

This commit is contained in:
zzz
2015-05-06 01:51:57 +00:00
parent 77c9a644ac
commit 2aafc23774
5 changed files with 13 additions and 0 deletions

View File

@ -87,6 +87,8 @@ abstract class PersistDHT {
out.println(ni.toPersistentString());
count++;
}
if (out.checkError())
throw new IOException("Failed write to " + file);
} catch (IOException ioe) {
if (log.shouldLog(Log.WARN))
log.warn("Error writing the DHT File", ioe);

View File

@ -112,6 +112,8 @@ public class SubscriptionsBean extends BaseBean
out.println(url);
}
out.close();
if (out.checkError())
throw new IOException("Failed write to " + file);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();

View File

@ -53,6 +53,8 @@ public class CertUtil {
}
wr.println("-----END CERTIFICATE-----");
wr.flush();
if (wr.checkError())
throw new IOException("Failed write to " + file);
return true;
} catch (CertificateEncodingException cee) {
error("Error writing X509 Certificate " + file.getAbsolutePath(), cee);

View File

@ -529,6 +529,11 @@ public class DataHelper {
out.flush();
fos.getFD().sync();
out.close();
if (out.checkError()) {
out = null;
tmpFile.delete();
throw new IOException("Failed to write properties to " + tmpFile);
}
out = null;
if (!FileUtil.rename(tmpFile, file))
throw new IOException("Failed rename from " + tmpFile + " to " + file);

View File

@ -322,6 +322,8 @@ public class WorkingDir {
out.println(s);
}
System.err.println("Copied " + oldFile + " with modifications");
if (out.checkError())
throw new IOException("Failed write to " + newFile);
return true;
} catch (IOException ioe) {
if (in != null) {