如果使用:
  int ch;
  while ( (ch = bufferedReader.read()) != -1) {
     stringBuffer.append( (char) ch);
  }
  stringBuffer.toString()速度有所提高(差不得等10秒),但还是不能根本解决问题.

解决方案 »

  1.   

    import java.io.IOException;
    import java.io.RandomAccessFile;
    import java.nio.ByteBuffer;
    import java.nio.channels.FileChannel;public class BigString {
        public static void main(String[] args) throws IOException {
            FileChannel fc = new RandomAccessFile("manual.html", "r").getChannel();
            ByteBuffer bb = ByteBuffer.allocate((int) fc.size());
            fc.read(bb);
            long start = System.currentTimeMillis();
            String bigStr = new String(bb.array(), "UTF-8");
            long end = System.currentTimeMillis();
            System.out.println("cost: " + (end - start) + "ms");
        }
    }测试文件选用 MySQL 的 manual.html(3MB) 文件
    Athlon 2500+ 耗时 203 毫秒
      

  2.   

    用 UltraEdit 看了一下 manual.html 有12万行
    真不知道 MySQL 怎么想的...
      

  3.   

    你这方法不错,留着
    mysql的文档本来就挺烂的
      

  4.   

    registered(已注册) :我对你的敬仰有如滔滔江水、绵绵不绝……