Java IO Tutorial - Java CharsetDecoder.charset()








Syntax

CharsetDecoder.charset() has the following syntax.

public final Charset charset()

Example

In the following code shows how to use CharsetDecoder.charset() method.

//from w ww  .  j a  v a 2 s .  co m
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();

    System.out.println(decoder.charset());
  }
}

The code above generates the following result.