手动加载 Java 字符集

Loading a Java Charset manually(手动加载 Java 字符集)
本文介绍了手动加载 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 UnsupportedEncodingExceptions, 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 字符集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How can create a producer using Spring Cloud Kafka Stream 3.1(如何使用Spring Cloud Kafka Stream 3.1创建制片人)
Insert a position in a linked list Java(在链接列表中插入位置Java)
Did I write this constructor properly?(我是否正确地编写了这个构造函数?)
Head value set to null but tail value still gets displayed(Head值设置为空,但仍显示Tail值)
printing nodes from a singly-linked list(打印单链接列表中的节点)
Control namespace prefixes in web services?(控制Web服务中的命名空间前缀?)