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

📄 e167. persisting changes to a memory-mapped bytebuffer.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
Changes to a memory-mapped ByteBuffer are not necessarily sent immediately to the underlying storage device. In some applications, such as with a memory-mapped register, the change should be sent immediately. The MappedByteBuffer.force() method is used to force all changes to the underlying storage device immediately. 
    try {
        // Create a ByteBuffer on a memory-mapped file
        File file = new File("filename");
        FileChannel channel = new RandomAccessFile(file, "rw").getChannel();
        MappedByteBuffer buf = channel.map(FileChannel.MapMode.READ_WRITE, 0, (int)channel.size());
    
        // Make a change to the ByteBuffer
        buf.put(0, (byte)0xFF);
    
        // Force the change to the file system
        buf.force();
    
        // Close the file
        channel.close();
    } catch (IOException e) {
    }

⌨️ 快捷键说明

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