利用InputStreamReader的read()方法读取时有乱码
读取.docx结尾的文件时有乱码,读取.txt文件时控制台正常输出
public static void main(String[] args) throws IOException{
InputStreamReader in=new InputStreamReader(new FileInputStream("F:\\src.docx"),"gbk");
int c;
while((c=in.read())!=-1){
System.out.print((char)c);
}
/*char[] buf=new char[200];
int c;
while((c=in.read(buf,0,buf.length))!=-1){
String s=new String(buf,0,buf.length);
System.out.print(s);
}*/
in.close();
}