大家好:
   在这里请教各位高手一个问题.我需要读取一个txt文件(1G多)而后写入到oralce数据库里面去.请问各位高手有什么好的办法解决.最主要是提高速度.谢谢先了.

解决方案 »

  1.   

    用nio,获得一个FileChannel,然后用MappedByteBuffer操作数据。
    这是一个tij上面的例子,可以把length改大就好了:
    import java.io.*;
    import java.nio.*;
    import java.nio.channels.*;public class LargeMappedFiles {
      static int length = 0x8FFFFFF; // 128 Mb
      public static void main(String[] args) throws Exception {
        MappedByteBuffer out = 
          new RandomAccessFile("test.dat", "rw").getChannel()
          .map(FileChannel.MapMode.READ_WRITE, 0, length);
        for(int i = 0; i < length; i++)
          out.put((byte)'x');
        System.out.println("Finished writing");
        for(int i = length/2; i < length/2 + 6; i++)
          System.out.print((char)out.get(i));
      }
    }