手动解码
public static void main(String[] args) throws FileNotFoundException, IOException {
InputStream in = new FileInputStream("test.txt");
byte [] buf=new byte[1024];
int len=0;
while ((len = in.read()) != -1){
System.out.print(new String(buf,0,len,"GBK"));//用GBK来解码,或者可以改成"utf-8"就是UTF-8的解码方式,按自己的需求来。
}
in.close();
} |