我刚刚以question为止就这个问题停了下来。
说我喜欢这个。 (请注意,我使用"rw"
而非"rws"
或"rwd"
)。
try(RandomAccessFile raw = new RandomAccessFile(file, "rw")) {
// write some
}
RandomAccessFile#close()
是否明确地执行getFD().sync()
?
try(RandomAccessFile raw = new RandomAccessFile(file, "rw")) {
// write some
raw.getFD().sync();
}
我搜索了RandomAccessFile.java
,而来源就是
public void close() throws IOException {
// doin' here, things look like irrelevant
close0();
}
private native void close0() throws IOException;