This is a facade method for encoding operation.
This method encodes the remaning character sequence of the given character buffer into a new byte buffer. This method performs a complete encoding operation, resets at first, then encodes, and flushes at last.
This method should not be invoked if another encode operation is ongoing.
@param in the input buffer
@return a new
ByteBuffer
containing the the bytes producedby this encoding operation. The buffer's limit will be the position of last byte in buffer, and the position will be zero
@throws IllegalStateException if another encoding operation is ongoing
@throws MalformedInputException if illegal input character sequence for this charset encountered, and the action for malformed error is {@link CodingErrorAction#REPORT CodingErrorAction.REPORT}
@throws UnmappableCharacterException if legal but unmappable input character sequence for this charset encountered, and the action for unmappable character error is {@link CodingErrorAction#REPORT CodingErrorAction.REPORT}. Unmappable means the Unicode character sequence at the input buffer's current postion cannot be mapped to a equivalent byte sequence.
@throws CharacterCodingException if other exception happened during the encode operation