JAVA NIO Buffer
发布日期:2021-05-09 05:38:08 浏览次数:19 分类:博客文章

本文共 5380 字,大约阅读时间需要 17 分钟。

���������������������������������������������������������������������

 

 

���������������������������������������JVM������

������������������������������������������������������������������������������������������������������������������������������������

������������������������������������������������������������

  1. ���������������������������������������������������������

  2. ������������������������������������������������������

���������������������������--������������������������������������������������������������������������������������������������������������������������������������

 

 

 

���������������������������������������������

 

������������

 

���������������������������������������������������������������Buffer������������������������������������������������������������������������������API��� 

���������������������������0<=mark<=position<=limit<=capicity

  1. ���������Capicity���������������������������������������������

  2. ���������Limit���������������������������

  3. ���������Position������������������������������������������������������������

  4. ���������Mark���������������������mark()������mark=position���reset()������postion=mark���

 

���������hello������������

 

 

Buffer������������������

������Buffer������������������������������������������������

���������������������������ByteBuffer���

ByteBuffer bf = ByteBuffer.allocate(1024).asReadOnlyBuffer()

Flip()������������������������������������������������������������������������������������������������������������������������

bf.flip() = bf.limit(bf.position()).position(0)

 

 

rewind():

bf.rewind() = bf.position(0)

������������������������������

mark()���Buffer������������������������������������������������������������������������������ow������position���6

 

 

reset()������positon���mark���������

���������������������������Buffer���������������������������������������������������������������equals=true���

 

Buffer.get(byte[])���BufferUnderflowException���

������������buffer���������������������buffer���������������������������������������������������������������������������������������buffer������������������������

Buffer.get(byte[], 0, Buffer.remaining());

Buffer.put(byte[])���BufferUnderflowException���

������������������������buffer���buffer������������������������������������������������

Buffer.wrap(byte[], int offset, int length)���offset���length������������������������������������������������������������������������������������������������������������������������������������������slice���������

allocate(), wrap() ������������������������������������������������������������������������������������������

Duplicate()������������������������������������Buffer���������������������������������������������������������������������������������������������

Slice() ������������������������������������������������������������������������������������������������������������limit-position������������������������������������������������������������������������������������������������������������������

 

 

������������������������������������������������������������������������������������������������������������������������������������������endian-ness)������������������������������������--big-end���������������������������������������������������������������������������������������������������

IP���������������������������������������������������������

������ByteOrder.nativeOrder() ������LITTLE_ENDIAN������BIG_ENDIAN���������

Java���������������������������������������������������ByteBuffer.order() ������������ByteOrder.BIG_ENDIAN���

������������������������������������IO���������IO������������������������������������������������������JVM���������������������������������������������������GC������������������������������������IO���������������������

���������������������������������������IO������������������������������������������������������������������������

���������������=���������

������������������=������������������������=���IO=���������������������������������

���������������������������������������������������������������

���������������������������������������������������������������������������JVM���������������������������������������������������������������������������������

���������������������������������������������������������������������������������������������������������

ByteBuffer.allocateDirect()������������������������

������������������

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ByteBuffer���������������������������byte������������������������������������������������ByteBuffer.asLongBuffer()���������������������������������������������������������������������������position-limit���

 

���������ByteBuffer.asCharBuffer():

ByteBuffer���������������������������CharBuffer���������������������CharBuffer���������������������������������������

���������������������

������������������������������byte������������������������������

���ByteBuffer���������������������������������������������������������������������������������������������������������������������������������������

������getInt()������������������������������������������������������������Int������������������

 

������������������MappedByteBufefer)���

������������������������������������������������������������������������������������FileChannel������������

上一篇:JAVA NIO Channel
下一篇:MTU(Maximum transmission unit) 最大传输单元

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2025年04月24日 15时19分22秒