int len=0;
byte[] b=new byte[100];
Properties pps=System.getProperties();
pps.put("file.encoding","ISO-8859-1");
FileInputStream fis=new FileInputStream("cunbin.txt");
len=fis.read(b);
System.out.println(new String(b,0,len));/*cunbin.txt存放内容:存斌*/
/*如果编码方式是ISO-8859-1,汉字应该无法输出的啊,但是我的电脑上能正常输出那两字*/
/*我用的是jdk1.6的*/
byte[] b=new byte[100];
Properties pps=System.getProperties();
pps.put("file.encoding","ISO-8859-1");
FileInputStream fis=new FileInputStream("cunbin.txt");
len=fis.read(b);
System.out.println(new String(b,0,len));/*cunbin.txt存放内容:存斌*/
/*如果编码方式是ISO-8859-1,汉字应该无法输出的啊,但是我的电脑上能正常输出那两字*/
/*我用的是jdk1.6的*/
是的话请设置
eclipse中run -- run configurations -- common -- console encoding
这个设置决定了你eclpise中控制台字符显示
就能把所有文件的编码形式改过来?文件在写入时编码,写入时如果设置编码形式为latin1你写汉字进去,不用java也会发现读不出来的
比如
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(reportFile), "ISO-8859-1"));
System.setProperty("file.encoding","ISO-8859-1");
or
Properties p = new Properties();
p.put("file.encoding","ISO-8859-1");
System.setProperties(p);