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

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

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

    zhyiwww
    用平實(shí)的筆,記錄編程路上的點(diǎn)點(diǎn)滴滴………
    posts - 536,comments - 394,trackbacks - 0

    This example implements a method that reads the entire contents of a file into a byte array.


    ?// Returns the contents of the file in a byte array.

    				
    						
    								    public static byte[] getBytesFromFile(File file) throws IOException {
    InputStream is = new FileInputStream(file);

    // Get the size of the file
    long length = file.length();

    // You cannot create an array using a long type.
    // It needs to be an int type.
    // Before converting to an int type, check
    // to ensure that file is not larger than Integer.MAX_VALUE.
    if (length > Integer.MAX_VALUE) {
    // File is too large
    }

    // Create the byte array to hold the data
    byte[] bytes = new byte[(int)length];

    // Read in the bytes
    int offset = 0;
    int numRead = 0;
    while (offset < bytes.length
    && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
    offset += numRead;
    }

    // Ensure all the bytes have been read in
    if (offset < bytes.length) {
    throw new IOException("Could not completely read file "+file.getName());
    }

    // Close the input stream and return bytes
    is.close();
    return bytes;
    }



    |----------------------------------------------------------------------------------------|
                               版權(quán)聲明  版權(quán)所有 @zhyiwww
                引用請注明來源 http://www.tkk7.com/zhyiwww   
    |----------------------------------------------------------------------------------------|
    posted on 2006-06-13 12:05 zhyiwww 閱讀(483) 評論(0)  編輯  收藏 所屬分類: code demo -java
    主站蜘蛛池模板: 亚洲精品国产av成拍色拍| 色久悠悠婷婷综合在线亚洲 | 免费VA在线观看无码| 亚洲精品国产日韩无码AV永久免费网 | 狠狠亚洲狠狠欧洲2019| 久久精品国产亚洲AV高清热| 青青操免费在线视频| 国产亚洲精品AA片在线观看不加载 | 国产免费小视频在线观看| 色婷婷六月亚洲综合香蕉| 免费国产在线观看老王影院| 亚洲Av无码专区国产乱码DVD| 亚洲人成小说网站色| 最近最新中文字幕完整版免费高清 | 亚洲国产精品综合久久2007| 性xxxxx免费视频播放| avtt亚洲天堂| 亚洲人成网站看在线播放| caoporn成人免费公开| 亚洲欧洲精品无码AV| 中文字幕在线观看免费视频 | 亚洲AV无码专区在线厂| 亚洲一区免费观看| 亚洲精品A在线观看| 三年片在线观看免费西瓜视频| 四色在线精品免费观看| 在线观看亚洲电影| 在线观看无码的免费网站| 国产青草亚洲香蕉精品久久| 亚洲永久无码3D动漫一区| **毛片免费观看久久精品| 亚洲日韩AV一区二区三区中文| 亚洲国产精品专区在线观看| 免费高清国产视频| 久久99国产亚洲高清观看首页| 黄色毛片免费在线观看| 免费黄色毛片视频| 精品亚洲成在人线AV无码| 亚洲а∨天堂久久精品| 日韩av无码久久精品免费| 黄页网站在线观看免费|