一般的系统都是默认GBK编码,你用UTF-8去解析GBK,当然会出现乱码。你将UTF-8改成GBK就可以l
import java.util.*;
class TestCode1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in, "GBk");//出现乱码
String name = null;
System.out.println("请输入名字:");
name = input.next();
System.out.println("您刚才输入的名字:" + name);
}
} |
|