想要在控制台中打印 记事本中的内容 记事本中的内容是 "gyugf屌丝你好gjhgh"
打印出来的结果是"?gyugf屌丝你好gjhgh" 多出来了一个 ?号.
记事本的编码格式改成了 utf-8
代码如下:
File file =new File("E:/1234.txt");
byte []Byte=new byte[(int)file.length()];
FileInputStream in=new FileInputStream(file);
in.read(Byte);
String s=new String(Byte,"utf8");
System.out.println(s);
打印出来的结果是"?gyugf屌丝你好gjhgh" 多出来了一个 ?号.
记事本的编码格式改成了 utf-8
代码如下:
File file =new File("E:/1234.txt");
byte []Byte=new byte[(int)file.length()];
FileInputStream in=new FileInputStream(file);
in.read(Byte);
String s=new String(Byte,"utf8");
System.out.println(s);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货