Java IO Tutorial - Java Charset.defaultCharset()








Syntax

Charset.defaultCharset() has the following syntax.

public static Charset defaultCharset()

Example

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

import java.nio.charset.Charset;
/* w  w w  .j a va 2 s.c o m*/
public class Main {

  public static void main(String[] args) {
    
      Charset cs = Charset.defaultCharset();
      System.out.println(cs.displayName());
      System.out.println(cs.toString());

  }
}

The code above generates the following result.