OiO.lk Blog java How to flush a RandomAccessFile?
java

How to flush a RandomAccessFile?


I use "rw" mode and want to flush content into device:

RandomAccessFile random= new RandomAccessFile(path.toFile(), "rw");
random.write(1);

But they always failed on flush operation:

//Force failed
random.getChannel().force(true);

or

//sync failed
random.getFD().sync();

There is no detail reason:

sync failed
java.io.SyncFailedException: sync failed
    at java.io.FileDescriptor.sync(Native Method)

Other modes also produce the same error:"rwd","rws". Why and how to solve?



You need to sign in to view this answers

Exit mobile version