t*g 发帖数: 1758 | 1 中文文件里面有4个字"萨尔加多",utf-8 encoding.
下面是code
public static void main(String[] args) {
String queries="c:\\temp\\qauto.txt";
try{
BufferedReader in = new BufferedReader(new InputStreamReader(new
FileInputStream(queries),"UTF-8"));
String str=in.readLine();
System.out.println(str+"length"+str.length());
}catch(Exception e){
e.printStackTrace();
}
}
打印出来是5个字符。为什么?好像在第三个和第四个中间加了一个。eclipse的console
没法给我显示中文输出。谢谢! | k***r 发帖数: 4260 | 2 To display UTF-8 in eclipse, go to Run dialog, Common tab, Console Encoding,
set to utf-8
【在 t*g 的大作中提到】 : 中文文件里面有4个字"萨尔加多",utf-8 encoding. : 下面是code : public static void main(String[] args) { : : String queries="c:\\temp\\qauto.txt"; : try{ : BufferedReader in = new BufferedReader(new InputStreamReader(new : FileInputStream(queries),"UTF-8")); : String str=in.readLine(); : System.out.println(str+"length"+str.length());
|
|