问题如题,以下是代码  public String initEmailHtml(String htmlpath) {
InFile fileinputstream;
String str="";
Reader reader = null;
String line = null;
try {
reader = new BufferedReader(new FileReader(htmlpath)); do {
line = ((BufferedReader)reader).readLine();
if (line != null && !line.equals(""))  { // 曾加了判断为空时候的情况
line = line.trim();
System.out.println(line);
}
} while (line != null);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}

解决方案 »

  1.   

    line=new String(line.getBytes(),"你的中文文件的编码类型");
    比如line=new String(line.getBytes(),"GBK")
    貌似
      

  2.   

    最好是先把内容用inputstream读入成字节
    然后用new String(byte[],"charset");转化成字符串
      

  3.   

    java.io.FileInputStream fin = new FileInputStream(你文件的路径)
    InputStreamReader reader = new InputStreamReader(fin, 你文件的字符编码)
      

  4.   

    顶Squall1009
    你可以试试做个过滤器把你要过滤的文件的后缀写上或就用*.*过滤全部文件