package com.day9;
import java.nio.ByteBuffer;
public class NIoTest {
public static void main(String[] args) {
String str = "abcde";
//创建字节缓冲区 capacity容量
ByteBuffer buffer = ByteBuffer.allocate(1024);
System.out.println("========nio创建buffer初始状态==========");
System.out.println("缓冲区的指定容量:"+buffer.capacity());
System.out.println("缓冲区的可读界限"+buffer.limit());
System.out.println("缓冲区操作数据的位置:"+buffer.position());
System.out.println("============buffer存入字节数组=====================");
//利用put 存入缓冲区
buffer.put(str.getBytes())