Java IO Tutorial - Java Charset.newDecoder()








Syntax

Charset.newDecoder() has the following syntax.

public abstract CharsetDecoder newDecoder()

Example

In the following code shows how to use Charset.newDecoder() method.

import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
/*from  www .  j a v  a 2 s .c  om*/
public class Main {

  public static void main(String[] args) {
    Charset inCharset = Charset.forName("UTF8");
    Charset outCharset = Charset.forName("UTF16");

    CharsetDecoder inDecoder = inCharset.newDecoder();
    CharsetEncoder outEncoder = outCharset.newEncoder();

  }
}