<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 鹽城小土包 閱讀(166) 評論(0)  編輯  收藏 所屬分類: J2EE

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導航

    統計

    常用鏈接

    留言簿

    隨筆檔案(14)

    文章分類(18)

    文章檔案(18)

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲色大成网站www永久网站| 香港a毛片免费观看| 一级做受视频免费是看美女| 免费观看的毛片大全| 亚洲噜噜噜噜噜影院在线播放| 曰批全过程免费视频观看免费软件 | 免费在线看黄的网站| 亚洲色婷婷六月亚洲婷婷6月| 又硬又粗又长又爽免费看| 久章草在线精品视频免费观看| 在线免费观看色片| 丁香婷婷亚洲六月综合色| 两个人看的www免费| 亚洲成年轻人电影网站www| 亚洲精品视频在线观看免费| xvideos亚洲永久网址| 亚洲午夜在线一区| 午夜a级成人免费毛片| 国产精品亚洲а∨天堂2021| 6080午夜一级毛片免费看6080夜福利| 免费国产成人高清在线观看麻豆| 亚洲乱码中文字幕手机在线| 免费精品视频在线| 亚洲午夜未满十八勿入网站2| 美女羞羞视频免费网站| ZZIJZZIJ亚洲日本少妇JIZJIZ | 无码国模国产在线观看免费| 美女18毛片免费视频| 亚洲乱码中文字幕综合| 在线观看亚洲免费视频| 久久亚洲2019中文字幕| 日韩在线视频播放免费视频完整版| 国产香蕉九九久久精品免费| 国产偷国产偷亚洲高清人| 日韩中文字幕免费| 中文字幕的电影免费网站| 久久久久亚洲AV无码观看| 内射无码专区久久亚洲| 国产亚洲成在线播放va| 亚洲va久久久噜噜噜久久狠狠| 免费萌白酱国产一区二区三区|