The spec for CharsetEncoder.flush states
If this method completes successfully then it returns CoderResult.UNDERFLOW. If there is insufficient room in the output buffer then it returns CoderResult.OVERFLOW. If this happens then this method must be invoked again, with an output buffer that has more room, in order to complete the current encoding operation.
However, the implementation unconditionally throws an IllegalStateException
if flush is invoked twice, even if it returned UNDERFLOW the first time.
This happens with any encoder or decoder with a non-trivial flush method.
Exception in thread "main" java.lang.IllegalStateException: Current state = FLUSHED, new state = FLUSHED
###@###.### 2005-2-10 02:34:26 GMT
If this method completes successfully then it returns CoderResult.UNDERFLOW. If there is insufficient room in the output buffer then it returns CoderResult.OVERFLOW. If this happens then this method must be invoked again, with an output buffer that has more room, in order to complete the current encoding operation.
However, the implementation unconditionally throws an IllegalStateException
if flush is invoked twice, even if it returned UNDERFLOW the first time.
This happens with any encoder or decoder with a non-trivial flush method.
Exception in thread "main" java.lang.IllegalStateException: Current state = FLUSHED, new state = FLUSHED
###@###.### 2005-2-10 02:34:26 GMT
- duplicates
-
JDK-6374012 nio charset encoder problem when flushing during OVERFLOW
-
- Closed
-
- relates to
-
JDK-6221056 (cs) CharsetEncoder.encode(ByteBuffer) should call flush(ByteBuffer)
-
- Resolved
-