类 Buffers
- java.lang.Object
-
- net.dongliu.commons.io.Buffers
-
public class Buffers extends java.lang.ObjectUtils for buffers
-
-
构造器概要
构造器 构造器 说明 Buffers()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static voidadvance(java.nio.Buffer buffer, int step)Increase buffer position to new position, by step. if step is less than zero, the position is moved back.static intensureGetUInt(java.nio.ByteBuffer buffer)Get four bytes, as unsigned long value from buffer.static longensureGetULong(java.nio.ByteBuffer buffer)Get eight bytes, as unsigned long value from buffer.static shortgetUByte(java.nio.ByteBuffer buffer)Get a byte, as unsigned byte from buffer.static longgetUInt(java.nio.ByteBuffer buffer)Get four bytes, as unsigned int value from buffer.static intgetUShort(java.nio.ByteBuffer buffer)Get two bytes, as unsigned short value from buffer.static java.nio.ByteBufferslice(java.nio.ByteBuffer buffer)This method return a subsequent buffer asByteBuffer.slice(), with additional set the byte order of sliced new ByteBuffer to the same of original buffer.
-
-
-
方法详细资料
-
advance
public static void advance(java.nio.Buffer buffer, int step)Increase buffer position to new position, by step. if step is less than zero, the position is moved back.- 参数:
buffer- the bufferstep- the step to increase the position- 抛出:
java.nio.BufferOverflowException- if new position is not a valid position.
-
slice
public static java.nio.ByteBuffer slice(java.nio.ByteBuffer buffer)
This method return a subsequent buffer asByteBuffer.slice(), with additional set the byte order of sliced new ByteBuffer to the same of original buffer.- 参数:
buffer- the origin buffer- 返回:
- the new buffer hold the remain data of original buffer
-
getUByte
public static short getUByte(java.nio.ByteBuffer buffer)
Get a byte, as unsigned byte from buffer.- 返回:
- a short value hold the unsigned byte.
-
getUShort
public static int getUShort(java.nio.ByteBuffer buffer)
Get two bytes, as unsigned short value from buffer.- 返回:
- a int value hold the unsigned short value.
-
getUInt
public static long getUInt(java.nio.ByteBuffer buffer)
Get four bytes, as unsigned int value from buffer.- 返回:
- a long value hold the unsigned int value.
-
ensureGetUInt
public static int ensureGetUInt(java.nio.ByteBuffer buffer)
Get four bytes, as unsigned long value from buffer. If the value can not hold in unsigned int, a exception thrown.- 返回:
- a int value hold the unsigned int value.
- 抛出:
java.lang.ArithmeticException- if int can not hold this unsigned int value
-
ensureGetULong
public static long ensureGetULong(java.nio.ByteBuffer buffer)
Get eight bytes, as unsigned long value from buffer. If the value can not hold in unsigned long, a exception thrown.- 返回:
- a long value hold the unsigned long value.
- 抛出:
java.lang.ArithmeticException- if long can not hold this unsigned long value
-
-