Code example for ByteBuffer

Methods: position, rewind, slice

0
 
	public MessageParseException(String message, ByteBuffer buff) {
		super(message);
		if (null == buff)
			return; 
		if (buff.position() > 0) //已经读取了一些数据
			buff.rewind();
		buffer = buff.slice();
	} 
 
    @Override 
	public String getMessage() {
		String message = super.getMessage();
 
		if (message == null) {
			message = "";
		} 
 
		if (buffer != null) {
			return message + ((message.length() > 0) ? " " : "") + "(Hexdump: "
					+ ')';