使用 文件映射 MapperByteBuffer 做对大文件的处理!!!

解决方案 »

  1.   

    部分代码片段,
    详见,JAVA_DOC文档import java.nio.MappedByteBuffer;
    import java.nio.channels.FileChannel;
    ...
        void countCharacters (String filename) 
        throws IOException {
            FileInputStream fis = new FileInputStream(filename);
            FileChannel fc = fis.getChannel();        // Get the file's size and then map it into memory
            int sz = (int)fc.size();
            MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);        for (int i=0; i= 0) && (pos <= 25)) {
                    ++countArray[pos];
                }
            }
            fc.close();
        }
    ...
      

  2.   

    可以试一下JEditorPane或JTextPane这两个组件能包括图像及其他组件,我想能解决你的大容量文件问题。
    新年新收获!