本文整理汇总了Java中java.nio.charset.spi.CharsetProvider.charsetForName方法的典型用法代码示例。如果您正苦于以下问题:Java CharsetProvider.charsetForName方法的具体用法?Java CharsetProvider.charsetForName怎么用?Java CharsetProvider.charsetForName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.charset.spi.CharsetProvider
的用法示例。
在下文中一共展示了CharsetProvider.charsetForName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lookupExtendedCharset
import java.nio.charset.spi.CharsetProvider; //导入方法依赖的package包/类
private static Charset lookupExtendedCharset(String charsetName) {
if (!VM.isBooted()) // see lookupViaProviders()
return null;
CharsetProvider[] ecps = ExtendedProviderHolder.extendedProviders;
for (CharsetProvider cp : ecps) {
Charset cs = cp.charsetForName(charsetName);
if (cs != null)
return cs;
}
return null;
}
示例2: lookupExtendedCharset
import java.nio.charset.spi.CharsetProvider; //导入方法依赖的package包/类
private static Charset lookupExtendedCharset(String charsetName) {
CharsetProvider ecp = null;
synchronized (extendedProviderLock) {
if (!extendedProviderProbed) {
probeExtendedProvider();
extendedProviderProbed = true;
}
ecp = extendedProvider;
}
return (ecp != null) ? ecp.charsetForName(charsetName) : null;
}
示例3: forName
import java.nio.charset.spi.CharsetProvider; //导入方法依赖的package包/类
/**
* Returns a {@code Charset} instance for the named charset.
*
* @param charsetName a charset name (either canonical or an alias)
* @throws IllegalCharsetNameException
* if the specified charset name is illegal.
* @throws UnsupportedCharsetException
* if the desired charset is not supported by this runtime.
*/
public static Charset forName(String charsetName) {
// Is this charset in our cache?
Charset cs;
synchronized (CACHED_CHARSETS) {
cs = CACHED_CHARSETS.get(charsetName);
if (cs != null) {
return cs;
}
}
// Is this a built-in charset supported by ICU?
if (charsetName == null) {
throw new IllegalCharsetNameException(charsetName);
}
checkCharsetName(charsetName);
cs = NativeConverter.charsetForName(charsetName);
if (cs != null) {
return cacheCharset(charsetName, cs);
}
// Does a configured CharsetProvider have this charset?
for (CharsetProvider charsetProvider : ServiceLoader.load(CharsetProvider.class, null)) {
cs = charsetProvider.charsetForName(charsetName);
if (cs != null) {
return cacheCharset(charsetName, cs);
}
}
throw new UnsupportedCharsetException(charsetName);
}
示例4: lookupExtendedCharset
import java.nio.charset.spi.CharsetProvider; //导入方法依赖的package包/类
private static Charset lookupExtendedCharset(String charsetName) {
CharsetProvider ecp = null;
synchronized (extendedProviderLock) {
if (!extendedProviderProbed) {
probeExtendedProvider();
extendedProviderProbed = true;
}
ecp = extendedProvider;
}
return (ecp != null) ? ecp.charsetForName(charsetName) : null;
}
示例5: lookupExtendedCharset
import java.nio.charset.spi.CharsetProvider; //导入方法依赖的package包/类
private static Charset lookupExtendedCharset(String charsetName) {
CharsetProvider ecp = ExtendedProviderHolder.extendedProvider;
return (ecp != null) ? ecp.charsetForName(charsetName) : null;
}
示例6: setup
import java.nio.charset.spi.CharsetProvider; //导入方法依赖的package包/类
@Before
public void setup() {
CharsetProvider provider = new Gsm7BitCharsetProvider();
charset = provider.charsetForName("X-Gsm7Bit");
}