Loading a Java Charset manually(手动加载 Java 字符集)
问题描述
I'm doing some work using the JavaMail API, and I've run across encodings which Java doesn't support natively (by design), such as UTF7/unicode-1-1-utf-7. For that encoding in particular I found the JUTF7 implementation of a Java Charset
and CharsetProvider
for UTF7. However, having added the jutf7.jar to my classpath I still get UnsupportedEncodingException
s, and unicode-1-1-utf-7 is definitely one of JUTF7's aliases.
Is there a way to manually load the Charset
or ensure that the Charset
is being loaded so that I can rule that out as a cause?
There's a bit more to using a new Charset, apart from putting the necessary classes into the classpath. To quote the Javadocs:
A charset provider identifies itself with a provider-configuration file named java.nio.charset.spi.CharsetProvider in the resource directory META-INF/services. The file should contain a list of fully-qualified concrete charset-provider class names, one per line. [...]
( http://download.oracle.com/javase/6/docs/api/java/nio/charset/spi/CharsetProvider.html )
Is this special file present in the JAR?
这篇关于手动加载 Java 字符集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:手动加载 Java 字符集


基础教程推荐
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 降序排序:Java Map 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01