Question:
How to find default encoding in java?
Code:
import java.io.*; public class DefaultCharacterEncoding { public static void main(String[] args) { byte [] array = {'w'}; InputStream is = new ByteArrayInputStream(array); InputStreamReader reader = new InputStreamReader(is); String dce = reader.getEncoding(); System.out.println("Default character encoding: " + dce); } }
Output:
$ java DefaultCharacterEncoding Default character encoding: UTF8