Online to find a lot of articles, and ultimately this article helped me solve the problem: http://blog.sina.com.cn/s/blog_5016ee390102e3xz.html (Thanks to the author of this article (*^__^*) hehe ... )
BufferedReader bf = new BufferedReader (new InputStreamReader (system.in));
String opertor = Bf.readline ();
String name1 = Bf.readline ();
System.out.println (NAME1);
This is a very common Java code to get keyboard input, but in the process of running, I found that as long as I entered the Chinese language, it is garbled.
Cause: Because the default character encoding for this open source project is UTF-8, the character encoding of my console is automatically changed to UTF-8, and the default format for the input stream of the keyboard is GBK format. This causes the odd garbled error (the explanation of this problem can be found in the search engine) in the process of GBK turning UTF-8.
Workaround:
1. Console encoding, Common (right), run configurations-R, right-click Code area
If this error occurs, the encoding format should be UTF-8, select Other, at this point there may be no GBK option, if not, then perform the operation after.
2. Change the text file encoding for the item, resource, properties, right-click, first adjust the text file encoding back to GBK, and then go back to reset console encoding encoding to GBK.
Many projects now require a unified character encoding before the start of the project to UTF-8, this is to better support internationalization, which can not avoid the console garbled this kind of comparison of the problem (at least I checked for a long time), so write it out for everyone to share ~
About System.in read the data, print out the problem of code breaker