在Java中确定平台的默认字符集 [英] Determining default character set of platform in Java

查看:260
本文介绍了在Java中确定平台的默认字符集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Java编程

我的代码为:

byte[] b = test.getBytes();

在api中指定如果我们不指定字符编码,则采用默认的平台字符编码。

In the api it is specified that if we do not specify character encoding it takes the default platform character encoding.

默认平台字符编码的含义是什么?

What is meant by "default platform character encoding" ?

这是指Java编码还是操作系统编码?

Does it mean the Java encoding or the OS encoding ?

如果它意味着操作系统编码,我该如何检查Windows和Linux的默认字符编码?无论如何我们可以使用命令行获取默认字符编码吗?

If it means OS encoding the how can i check the default character encoding of Windows and Linux ? Is there anyway we can get the default character encoding using command line ?

推荐答案

这意味着您的JVM的默认字符编码'正在运行,

It means the default character encoding of the JVM that you're running on,

要检查默认编码,您可以执行以下操作:

To check the default encoding you can do the following:

System.getProperty("file.encoding");

将返回默认编码(以及上面的getBytes()使用的编码。)

that will return the default encoding (and the one used by getBytes() above).

这篇关于在Java中确定平台的默认字符集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆