首页javanio_bufferJava I/O - 如何从字节数组中创建ByteBuffer

Java I/O - 如何从字节数组中创建ByteBuffer

我们想知道如何从字节数组中创建ByteBuffer。
import java.nio.ByteBuffer;

public class Main {
  public static void main(String[] argv) throws Exception {

    
    byte[] bytes = new byte[10];
    ByteBuffer buf = ByteBuffer.wrap(bytes);
  }
}