Do the operations in java.nio.files.Files sync or not?

Alan Bateman Alan.Bateman at oracle.com
Tue Aug 2 01:34:43 PDT 2011


Tim Fox wrote:
> Hello all,
>
> I'm looking at the javadoc for the new Files class in Java 7:
>
> http://download.oracle.com/javase/7/docs/api/
>
> For the operations that make changes on disk, it's not clear to me if 
> the changes are automatically sync'd to disk or not before the 
> operation completes. There don't seem to be any parameters to control 
> this.
>
>
>
> Can anyone advise?
>
> Thanks
The "Synchronized I/O File Integrity" section in the package javadoc is 
where this is discussed. Basically you use the SYNC or DSYNC options 
when opening files to indicate that the file content should be written 
synchronously to the disk. FileChannel also defines the force method.

-Alan.


More information about the nio-discuss mailing list