本帖最后由 yogaa 于 2014-6-8 15:25 编辑
我想看看我读取文件里的内容是什么,明明是汉字,但是为什么输出的是乱码,都已经做了编码转换了,求大神帮忙~代码如下:
public class IoTextAndCount {
public static void main(String[] args) throws IOException{
File f = new File("C:\\Users\\Administrator\\Desktop\\ds.txt");
FileInputStream fs = new FileInputStream(f);
InputStreamReader isr = new InputStreamReader(fs,"UTF-8");
BufferedReader br = new BufferedReader(isr);
String s;
StringBuffer sb = new StringBuffer();
while((s=br.readLine()) != null){
sb.append(s);
System.out.println(sb);
}
}
}
|
|