读出数据流到byte[]后转成String时用
new String(byte[], "UTF-8")的方法 或者"ISO-8859-1"编码!
不知道行不行?

解决方案 »

  1.   

    用Reader和Writer的相关类进行操作应该就可以的吧代码贴出来看看吧,不太清楚你错哪里了
      

  2.   

    FileReader text=new FileReader(c:\\aaa.txt);
    FileWriter letters=new FileWriter("c:\\ddd.txt");  
    String uni;
        while(!eof){
          String line=buff.readLine();      if(line==null) eof=true;
            else
            {
              uni = new  String(line.getBytes(),"GB2312").trim();
              letters.write(uni);
            }
        }或者    int inByte=text.read();
        while(inByte!=-1){
          if(inByte==10||inByte==13){}
          else letters.write(inByte);
          inByte=text.read();
        }都不行:(
      

  3.   

    是不是我的源文件aaa.txt有问题,在记事本里可以正常显示,但是在写字板里中文就变成乱码了,这是别的程序生成的文件,不知道是什么编码格式,可还是得解析它
      

  4.   

    忘了给出这个文件,不好意思,一定要帮个忙
    package Util;/**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2003</p>
     * <p>Company: </p>
     * @author not attributable
     * @version 1.0
     */public class ToolKit {
      public static String[] split(String str, String div, boolean isRegular) {
           String result[] = null; //返回结果集合
           String substr;       if (str == null || div == null) {
               return (null);
           }       if ((str = str.trim()).length() == 0)
               return (new String[]{str});       int cur = 0,
                   cnt = 0,
                   prv = cur,
                   end;       while (cur < str.length()) {           if ((end = str.indexOf(div, cur)) < 0) {
                   end = str.length();
               }           substr = str.substring(cur, end);
               if (isRegular) {
                   cnt += stringCount(substr, "(");
                   cnt -= stringCount(substr, ")");
               }
               if (isRegular == false || cnt == 0 || end == str.length()) {
                   substr = str.substring(prv, end);
                   if (result == null) {
                       result = new String[]{new String(substr)};
                   } else {
                       int len = result.length;
                       String array[] = new String[len + 1];                   for (int i = 0; i < len; i++)
                           array[i] = result[i];                   result = array;                   result[len] = new String(substr);
                   }
               }
               cur = end + div.length();
               if (isRegular == false || cnt == 0)
                   prv = cur;
           }
           return (result);
       }
       private static int stringCount(String str, String div) {
              int cnt = 0;
              int pos = 0;
              while ((pos = str.indexOf(div, pos)) >= 0) {
                  pos += div.length();
                  cnt++;
              }
              return cnt;
          }
        public static String[] split(String str, String div) {
          return split(str, div, false);
      }
      public static void main(String[] args) {
      }
    }
      

  5.   

    windows记事本可以将文件内容保存为以下四种编码方式:
    1、ANSI,不用说了
    2、UNICODE,头两个字节内容为 0xFF 0xFE,对应为 UTF-16LE
    3、UNICODE big endian,文字同样为UNICODE编码,只是字节顺序同2相反,以 0xFE 0xFF 开头,对应为 UTF-16BE
    4、UTF-8,这种编码方式在<JAVA核心技术 I>上面有讲述,头三个字节为0xEF 0xBB 0xBF, 对应为 UTF-8处理过程中先读出前三个字节内容判断出编码方式,然后再进行转换。