⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e027. forcing updates to a file to the disk.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
In some applications, such as transaction processing, it is necessary to ensure that an update has been made to the disk. FileDescriptor.sync() blocks until all changes to a file are written to disk. 
    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) {
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -