JAVA中的扫描仪输出乱码而不是希伯来语 [英] Scanner in JAVA outputs gibberish instead of Hebrew
问题描述
我在Netbeans中扫描希伯来语时遇到问题. 我正在尝试扫描用户的输入并显示在控制台中,但是它显示为乱码.
我的代码是:
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Please input:");
System.out.println("Your input is: " + input.next());
}
这是控制台:
运行:
请输入:
שלום
您的输入是:
成功完成(总时间:3秒)
相同的代码可以在Eclipse上完美运行. 如果我使用Println()希伯来语单词,它也可以正常工作,所以这不是编码问题. (我正在使用Netbeans 7.3.1)
非常感谢您,
巴拉克.
调用 and this is the Console: run: Please input: שלום Your input is: ���� BUILD SUCCESSFUL (total time: 3 seconds) The same exact code works perfectly on Eclipse.
If I Println() a hebrew word it also works fine, so it's not an encoding problem.
(I am using Netbeans 7.3.1) Thank you very much, Barak. When you call I suspect you simply need to work out what encoding your console is using, and use that either to construct an 这篇关于JAVA中的扫描仪输出乱码而不是希伯来语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!Scanner(InputStream)
, that will use the platform default encoding to convert the bytes from the stream into text.InputStreamReader
around System.in
to start with, or pass the encoding name as a second argument to the constructor.