默认编码为 ISO-8859-1
BufferedReader bis = new BufferedReader(new InputStreamReader(new FileInputStream("file having unicode characters"),"UTF-8"));
String strTemp = bis.readLine();// on debugging strTemp is having actual unicode data
System.out.println(strTemp);// uses default encoding which is ISO-8859-1,So not printing ///actual data
PrintStream psTemp = new PrintStream(System.out, true, "UTF-8");
psTemp.println(strTemp);// here i am giving encoding as UTF-8,still not printing unicode data.
即使我在 PrintStream 构造函数中将编码为 UTF-8,我也无法打印 unicode 数据,如果我将默认编码从 ISO-8859-1 更改为 UTF-8,它也可以工作。为什么会这样?