初识
package main.nio.netty.buf;import io.netty.buffer.ByteBuf;import io.netty.buffer.Unpooled;import java.io.File;import java.io.IOException;import java.io.RandomAccessFile;import java.nio.MappedByteBuffer;import java.nio.channels.FileChannel;/*** @Description ByteBuf** @Author Songxudong* @Date 2021/8/19 11:22 下午*/public class ByteBufDemo {public static void main(String[] args) {// 直接缓冲区,不适用JVM堆内存,使用堆外内存// 使用Unsafe的setMemory等内存操作方法实现ByteBuf byteBuf = Unpooled.directBuffer(128);File file = new File("jw.txt");try {FileChannel fc = new RandomAccessFile(file, "rw").getChannel();MappedByteBuffer map = fc.map(FileChannel.MapMode.READ_WRITE, 0, file.length());map.put("jiangwang".getBytes());fc.position(file.length());map.clear();fc.write(map);} catch (IOException e) {e.printStackTrace();}}}
简介
sdas
是的
function myFunction(p1, p2) {return p1 * p2; // 该函数返回 p1 和 p2 的乘积}
