本文整理汇总了Java中java.nio.charset.Charset.displayName方法的典型用法代码示例。如果您正苦于以下问题:Java Charset.displayName方法的具体用法?Java Charset.displayName怎么用?Java Charset.displayName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.charset.Charset
的用法示例。
在下文中一共展示了Charset.displayName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleDecodingError
import java.nio.charset.Charset; //导入方法依赖的package包/类
/**
* Handle an error thrown while file decoding. Inform search listener and
* append detailed info into the IDE Log.
*/
protected final void handleDecodingError(SearchListener listener,
FileObject file, CharsetDecoder decoder,
CharacterCodingException e) {
String charsetName;
try {
if (decoder.isAutoDetecting() && decoder.isCharsetDetected()) {
Charset c = decoder.detectedCharset();
if (c != null) {
charsetName = c.displayName();
} else {
charsetName = decoder.charset().displayName();
}
} else {
charsetName = decoder.charset().displayName();
}
} catch (Exception ex) {
LOG.log(Level.INFO, "Failed to obtain actual charset", ex); //NOI18N
charsetName = decoder == null ? "null" : decoder.toString();//NOI18N
}
String msg = NbBundle.getMessage(ResultView.class,
"TEXT_INFO_ERROR_ENCODING", charsetName); //NOI18N
listener.fileContentMatchingError(file.getPath(),
new Exception(msg, e));
LOG.log(Level.INFO, "{0}; UnmappableCharacterException: {1}", //NOI18N
new Object[]{file.getPath(), e.getMessage()});
}
示例2: availableCharsets
import java.nio.charset.Charset; //导入方法依赖的package包/类
@Override
public String[] availableCharsets() {
List<String> charsets = new Collection<String>();
for(Charset charset : Charset.availableCharsets().values()) {
final String name = charset.displayName();
if(!(name.startsWith("IBM") || ((name.startsWith("x-") && !name.startsWith("x-Mac"))))) {
charsets.add(name);
}
}
return charsets.toArray(new String[charsets.size()]);
}
示例3: load
import java.nio.charset.Charset; //导入方法依赖的package包/类
/**
* load the content of this page from a fetched HttpEntity.
* @param entity HttpEntity
* @param maxBytes The maximum number of bytes to read
* @throws Exception when load fails
*/
public void load(HttpEntity entity, int maxBytes) throws Exception {
contentType = null;
Header type = entity.getContentType();
if (type != null) {
contentType = type.getValue();
}
contentEncoding = null;
Header encoding = entity.getContentEncoding();
if (encoding != null) {
contentEncoding = encoding.getValue();
}
Charset charset = ContentType.getOrDefault(entity).getCharset();
if (charset != null) {
contentCharset = charset.displayName();
}else {
contentCharset = Charset.defaultCharset().displayName();
}
contentData = toByteArray(entity, maxBytes);
}