Code example for BufferOverflowException

0
        public MockMalfunctionDecoder(Charset cs) {
            super(cs, 1, 10);
        } 
 
        protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
            throw new BufferOverflowException();
        } 
    } 
 
    /* 
     * Mock encoder. encodeLoop always throws unexpected exception. 
     */ 
    static class MockMalfunctionEncoder extends java.nio.charset.CharsetEncoder {
 
        public MockMalfunctionEncoder(Charset cs) {
            super(cs, 1, 3, new byte[] { (byte) '?' });
        } 
 
        protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
            throw new BufferOverflowException();
Contextual code suggestions in your IDE  Get Codota for Java