本文整理汇总了Java中java.nio.charset.Charset.availableCharsets方法的典型用法代码示例。如果您正苦于以下问题:Java Charset.availableCharsets方法的具体用法?Java Charset.availableCharsets怎么用?Java Charset.availableCharsets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.charset.Charset
的用法示例。
在下文中一共展示了Charset.availableCharsets方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.nio.charset.Charset; //导入方法依赖的package包/类
public static void main(String[] args) {
SortedMap<String,Charset> charSets=
Charset.availableCharsets();
Iterator<String> it=charSets.keySet().iterator();
while (it.hasNext()){
String csName=it.next();
printnb(csName);
Iterator aliases=
charSets.get(csName).aliases().iterator();
if(aliases.hasNext()){
printnb(": ");
}
while (aliases.hasNext()){
printnb(aliases.next());
if(aliases.hasNext()){
printnb(", ");
}
}
print();
}
}
示例2: validateCharset
import java.nio.charset.Charset; //导入方法依赖的package包/类
private static String validateCharset(String cs)
{
if (!Charset.isSupported(cs))
{
System.err.println("Charset " + cs + " is not supported\n");
System.err.println("Available charsets:");
System.err.println("Default = " + Charset.defaultCharset());
Map<String,Charset> available = Charset.availableCharsets();
for (Entry<String, Charset> name: available.entrySet())
{
System.err.println(name.getKey() + " " + name.getValue().aliases());
}
System.err.println("");
usage("Charset " + cs + " is not supported");
}
return cs;
}
示例3: validateCharset
import java.nio.charset.Charset; //导入方法依赖的package包/类
private static String validateCharset(String cs)
{
if (!Charset.isSupported(cs))
{
println("Charset " + cs + " is not supported\n");
println("Available charsets:");
println("Default = " + Charset.defaultCharset());
Map<String,Charset> available = Charset.availableCharsets();
for (Entry<String, Charset> entry: available.entrySet())
{
println(entry.getKey() + " " + available.get(entry.getValue()).aliases());
}
println("");
usage("Charset " + cs + " is not supported");
}
return cs;
}
示例4: executeCommand
import java.nio.charset.Charset; //导入方法依赖的package包/类
@Override
public ShellStatus executeCommand(IEnvironment env, String arguments) {
try {
if (!arguments.equals("")) {
env.writeln("Invalid number of arguments for charsets command");
return ShellStatus.CONTINUE;
}
SortedMap<String, Charset> charsets = Charset.availableCharsets();
for (String charset : charsets.keySet()) {
env.writeln(charset);
}
} catch (Exception e) {
System.out.println("Unexpected error with command charsets!");
}
return ShellStatus.CONTINUE;
}
示例5: main
import java.nio.charset.Charset; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
SortedMap<String, Charset> map = Charset.availableCharsets();
for (String name : map.keySet()) {
Charset charset = map.get(name);
if (charset.canEncode() && !charset.name().equals("x-COMPOUND_TEXT")) {
testNormalSurrogate(charset, NORMAL_SURROGATE);
testMalformedSurrogate(charset, MALFORMED_SURROGATE);
testMalformedSurrogate(charset, REVERSED_SURROGATE);
testMalformedSurrogate(charset, SOLITARY_HIGH_SURROGATE);
testMalformedSurrogate(charset, SOLITARY_LOW_SURROGATE);
testSurrogateWithReplacement(charset, NORMAL_SURROGATE);
testSurrogateWithReplacement(charset, MALFORMED_SURROGATE);
testSurrogateWithReplacement(charset, REVERSED_SURROGATE);
testSurrogateWithReplacement(charset, SOLITARY_HIGH_SURROGATE);
testSurrogateWithReplacement(charset, SOLITARY_LOW_SURROGATE);
}
}
}
示例6: printAllCharsets
import java.nio.charset.Charset; //导入方法依赖的package包/类
private static void printAllCharsets() {
Map<String, Charset> all = Charset.availableCharsets();
System.out.println("\n=========================================\n");
for (String can : all.keySet()) {
System.out.println(can + ": " + all.get(can).aliases());
}
}