Force Updates to a File to the Disk in Java
Description
The following code shows how to force Updates to a File to the Disk.
Example
/*from www .jav a2 s . com*/
import java.io.FileDescriptor;
import java.io.FileOutputStream;
public class Main {
public static void main(String[] argv) throws Exception {
FileOutputStream os = new FileOutputStream("outfilename");
FileDescriptor fd = os.getFD();
os.write(1);
os.flush();
fd.sync();
}
}