Discussion:
Which one is recommended for SYNC on storage device?
Behrooz Nobakht
2014-07-26 10:16:48 UTC
Permalink
Hi,

Prior to Java 7, we'd use

FileOutputStream fos = new FileOutputStream(f);
fos.write(...)
fos.getFD().sync();

As of Java 7, we can say:

OutputStream os = Files.newOutputStream(path, StandardOpenOption.SYNC);

Regarding the behavior and the integrity, which one is more recommended?
Or, are both equivalent in the behavior?

Thanks,
Behrooz

Loading...