20230626 java.nio.ByteBuffer

发布时间 2023-08-29 17:08:03作者: 流星<。)#)))≦

介绍

  • java.nio.ByteBuffer
  • public abstract class ByteBuffer extends Buffer implements Comparable
  • 最常用的 Buffer 子类

API

static

  • allocateDirect
    • 直接使用本地内存,而不是通过 JVM 堆空间
  • allocate
  • wrap

public

  • get

  • put

  • compact

    • 压缩
    • 将缓冲区当前位置(position)与其限制(limit)之间的字符平移到缓冲区的开头
  • mismatch

    • 查找并返回此缓冲区与给定缓冲区之间第一个不匹配的相对索引
  • order

    • 检索此缓冲区的字节顺序
  • asReadOnlyBuffer

    • 创建一个共享此缓冲区内容的新的只读字符缓冲区
  • getChar, getShort, getInt, getLong, getFloat, getDouble

  • putChar, putShort, putInt, putLong, putFloat, putDouble

    • 操作基本数据类型
  • asCharBuffer, asShortBuffer, asIntBuffer, asLongBuffer, asFloatBuffer, asDoubleBuffer,

    • 转换为其他基本数据类型的 Buffer
  • alignmentOffset

  • alignedSlice