We can achieve the default charset through the java program. In our example java program we have created an object of FileWriter and then we will be using getEncoding() method for getting the default charset of this file writer.
Java get default Charset
We can achieve the default charset through the java program. In our example java program we have created an object of FileWriter and then we will be using getEncoding() method for getting the default charset of this file writer. For windows system it is by default set to the value Cp1252.
Here is the full example code of GetDefaultCharset.java as follows:
GetDefaultCharset.java
import java.io.*;
|
Output:
C:\javaexamples>javac GetDefaultCharset.java C:\javaexamples>java GetDefaultCharset Default encoding is : Cp1252 C:\javaexamples> |