Sync

try {
    // 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);

    // Flush the data from the streams and writers into system buffers.
    // The data may or may not be written to disk.
    os.flush();

    // Block until the system buffers have been written to disk.
    // After this method returns, the data is guaranteed to have
    // been written to disk.
    fd.sync();
} catch (IOException e) {
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.