Java examples for File Path IO:File Operation
Forcing Updates to a File to the Disk
import java.io.FileDescriptor; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void main(String[] argv) { try {//from www . j a v a 2s.c o m // Open or create the output file FileOutputStream os = new FileOutputStream("outfilename"); FileDescriptor fd = os.getFD(); // Write some data to the stream byte[] data = new byte[] { (byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE }; os.write(data); os.flush(); fd.sync(); } catch (IOException e) { } } }