如何查看JDK默认编码格式

  • Post author:
  • Post category:其他



import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;

class Test {
public static void main(String[] args) {
System.out.println("Default Charset=" + Charset.defaultCharset());
System.out.println("file.encoding=" + System.getProperty("file.encoding"));
System.out.println("Default Charset=" + Charset.defaultCharset());
System.out.println("Default Charset in Use=" + getDefaultCharSet());
}

private static String getDefaultCharSet() {
OutputStreamWriter writer = new OutputStreamWriter(new ByteArrayOutputStream());
String enc = writer.getEncoding();
return enc;
}

}



版权声明:本文为iteye_1457原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。