Java IO Tutorial - Java CharsetDecoder .flush (CharBuffer out)








Syntax

CharsetDecoder.flush(CharBuffer out) has the following syntax.

public final CoderResult flush(CharBuffer out)

Example

In the following code shows how to use CharsetDecoder.flush(CharBuffer out) method.

// w  ww  .ja va  2s . com
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;

public class Main {
  public static void main(String[] argv) throws Exception {
    Charset charset = Charset.forName("ISO-8859-1");
    CharsetDecoder decoder = charset.newDecoder();

    CharBuffer cbuf = CharBuffer.allocate(10);
    
    decoder.flush(cbuf);
  }
}