I am working on a Java application. We read lot of data, manipulate it and then write to files in local m/c. If, in any case, the disk is full then how to handle this exception in Java application.
You can take a look here.
This workaround solves the problem that no exception is thrown when your disk is full.
Basically, it is done by this:
FileOutputStream fos = ...;
fos.write("hello".getBytes());
fos.getFD().sync();
fos.close();
The call to the sync()
method will throw a SyncFailedException
, when the disk is full.
Can you specify more exactly what do you mean when you say how to handle this exception?
The way I see it there are two ways:
This is a good blog post on the topic: http://weblog.janek.org/Archive/2004/12/20/ExceptionWhenWritingToAFu.html
Also, this bug ticket for Java, explains various strategies: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4338871
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With