import java.io.IOException;
public class MyTest {public static void main(String[] args) throws IOException {
int b=System.in.read();
System.out.println(b);
}
}
输入:中
输出:214
问题:为什么输出为214 ,我知道"中"的unicode 编码为"4e2d",按照字节流中read()方法应该是读入一个字节"4e",这样b的转化为十进制应该为78,然而输出结果为214?请问其中问题出在哪?
public class MyTest {public static void main(String[] args) throws IOException {
int b=System.in.read();
System.out.println(b);
}
}
输入:中
输出:214
问题:为什么输出为214 ,我知道"中"的unicode 编码为"4e2d",按照字节流中read()方法应该是读入一个字节"4e",这样b的转化为十进制应该为78,然而输出结果为214?请问其中问题出在哪?
如果是windows用的是ASCII为解决Unicode和本地操作系统使用字符码转换的问题
java引入了一个InputStreamReader类
建议楼主看一下