本文整理匯總了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());
}
}