Where to get “UTF-8” string literal in Java?

前端 未结 11 855
谎友^
谎友^ 2020-12-02 03:51

I\'m trying to use a constant instead of a string literal in this piece of code:

new InputStreamReader(new FileInputStream(file), \"UTF-8\")
<
11条回答
  •  不知归路
    2020-12-02 04:38

    There are none (at least in the standard Java library). Character sets vary from platform to platform so there isn't a standard list of them in Java.

    There are some 3rd party libraries which contain these constants though. One of these is Guava (Google core libraries): http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/base/Charsets.html

提交回复
热议问题