本帖最后由 java2000_net 于 2008-08-05 09:19:33 编辑

解决方案 »

  1.   

    用字符流比用字节流快。有缓存比无缓存快。
    出现乱码是因为字符串没有定义编码。
    ep: String temp = new String(bytes,"utf-8");下面是我以前一个用于解析邮件文件并转编码的方法:    // 文件内容是base64编码的,还原成base64编码前的模样
        public static byte[] Base64Decode(String filename) {
            String original = null;
            FileInputStream fis = null;
            byte[] bytes = null;
            byte[] result = null;
            try {
                fis = new FileInputStream(filename);
                bytes = new byte[fis.available()];
                fis.read(bytes);
                original = new String(bytes);
    //            String temp = new String(bytes,"utf-8");
    //            original = new String(temp.getBytes("iso-8859-1"),"utf-8");
                result  = new sun.misc.BASE64Decoder().decodeBuffer(original.trim());   
            }
            catch (Exception ex) {
                ex.printStackTrace();
            }
            return result;
        }