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 ava2s .  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.





















Home »
  Java Tutorial »
    java.nio.charset »




Charset
CharsetDecoder
CharsetEncoder
StandardCharsets