<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    I/O Memory-mapped files

    Memory-mapped files allow you to create and modify files that are too big to bring into memory.
    With a memory-mapped file, you can pretend that the entire file is in memory and that you can access it by simply treating it as a very large array.
    /**
     * Creating a very large file using mapping
     * 
    @author WPeng
     *
     * 
    @since 2012-11-7
     
    */
    public class LargeMappedFiles {
        
    static int length = 0x8ffffff//128M
        public static void main(String[] args) throws FileNotFoundException, IOException {
            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.println((
    char)out.get(i));
            }
        }

    }

    To do both writing and reading, we start with a RandomAccessFile, get a channel for that file.
    And then call map() to produce a MppedByteBuffer, which is a particular kind of direct buffer.
    Note that you must specify the starting point and the length of  the region that you want to map in the file;
    this means that you have the option to map samller regions of a large file.

    The file createed with the preceding program is 128M long.
    which is probably larger than your OS will allow in memory at one time.
    the file appears to be accessible all at once because only portions of it are brought into memory.
    and other parts are swapped out.
    this way a very large file(up to 2 GB) can easily be modified.
    note that the file-mapping facilities of the underlying operating system are used to maximize performance.



    posted on 2012-11-07 14:59 鹽城小土包 閱讀(171) 評論(0)  編輯  收藏 所屬分類: J2EE

    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    導航

    統計

    常用鏈接

    留言簿

    隨筆檔案(14)

    文章分類(18)

    文章檔案(18)

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 2021国产精品成人免费视频| 成人最新午夜免费视频| 亚洲国产精品国产自在在线| 亚洲色大网站WWW永久网站| 免费在线看v网址| 国产精品视_精品国产免费| 国产亚洲成av人片在线观看| h片在线播放免费高清| 国产精品亚洲美女久久久| 亚洲免费在线视频| 亚洲欧洲av综合色无码| 国产三级在线免费观看| 亚洲女人被黑人巨大进入| caoporn国产精品免费| 亚洲成在人线av| 在线人成精品免费视频| 亚洲午夜在线一区| 免费看大美女大黄大色| 最好2018中文免费视频| 亚洲精品无码专区在线在线播放| 中文字幕av免费专区| 亚洲A∨无码无在线观看| 久久久久久久91精品免费观看| 亚洲乱码国产乱码精华| 亚洲国产精品国产自在在线| 久久九九全国免费| 2017亚洲男人天堂一| 四虎永久在线精品视频免费观看| 一级特黄录像视频免费| 亚洲高清中文字幕综合网| 高清国语自产拍免费视频国产| 黄色三级三级三级免费看| 色se01短视频永久免费| AV激情亚洲男人的天堂国语| 亚洲自偷自偷图片| 久久国内免费视频| 一级白嫩美女毛片免费| 亚洲免费网站在线观看| 亚洲精品黄色视频在线观看免费资源| 国产精品白浆在线观看免费| 国产精品亚洲综合久久|