我在 eclipse 中编写了这段代码来获取一些阿拉伯语单词,然后打印它们
public class getString {
public static void main(String[] args) throws Exception {
PrintStream out = new PrintStream(System.out, true, "UTF-8");
Reader r = new InputStreamReader(System.in, "UTF-8");
char[] str ;
str= new char[10];
r.read(str);
out.println(str);
}
}
但输出是这样的:
شیرین
有什么帮助吗?
提前感谢您的关注
最佳答案
只需通过窗口 > 首选项 > 常规 > 工作区 > 文本文件编码将工作区编码设置为 UTF-8。这也会影响 Eclipse 控制台中 stdout 的编码。
然后您也可以将 new PrintStream(System.out, true, "UTF-8")
替换为 System.out
。
关于java - 如何在 Eclipse 中用阿拉伯语读写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19169136/