public static void main(String args[]){
try{
FileInputStream fs = new FileInputStream("test.txt");
int i = fs.read();
while(i != -1){
System.out.println( i);
i = fs.read();
}
}catch(Exception e){
System.out.println(e);
}
}
Run Code Online (Sandbox Code Playgroud)
test.txt 文件包含“?”。输出为 196 140 。的 UTF-16 值?是 268 。你能帮我为什么答案是 196 和 140
如果不指定特定编码,Java 将使用“UTF-8”字符编码作为默认值。
UTF-8(十六进制)用于?是 0xC4 0x8C,分别转换为十进制为 196 和 140。使用 UTF-16 进行编码时,? 用十六进制值 0x010C 表示,转换为十进制为 268。
归档时间: |
|
查看次数: |
78 次 |
最近记录: |