Code example for CharBuffer

Methods: flip

0
     */ 
    public ReaderInputStream(Reader reader, CharsetEncoder encoder, int bufferSize) {
        this.reader = reader;
        this.encoder = encoder;
        this.encoderIn = CharBuffer.allocate(bufferSize);
        this.encoderIn.flip();
        this.encoderOut = ByteBuffer.allocate(128);
        this.encoderOut.flip();
    } 
 
    /** 
     * Construct a new {@link ReaderInputStream}. 
     *  
     * @param reader the target {@link Reader} 
     * @param charset the charset encoding 
     * @param bufferSize the size of the input buffer in number of characters 
     */ 
    public ReaderInputStream(Reader reader, Charset charset, int bufferSize) {
        this(reader,
             charset.newEncoder()
                    .onMalformedInput(CodingErrorAction.REPLACE)