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

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

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

    zhyiwww
    用平實的筆,記錄編程路上的點點滴滴………
    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;
    }



    |----------------------------------------------------------------------------------------|
                               版權聲明  版權所有 @zhyiwww
                引用請注明來源 http://m.tkk7.com/zhyiwww   
    |----------------------------------------------------------------------------------------|
    posted on 2006-06-13 12:05 zhyiwww 閱讀(478) 評論(0)  編輯  收藏 所屬分類: code demo -java
    主站蜘蛛池模板: 亚洲一区二区三区在线观看蜜桃| 国产亚洲AV夜间福利香蕉149| 亚洲欧洲日产韩国在线| 亚洲免费视频网站| 亚洲精品国产情侣av在线| 中国xxxxx高清免费看视频| 亚洲沟沟美女亚洲沟沟| 久久久久久精品成人免费图片| 亚洲欧洲另类春色校园小说| 免费精品国产日韩热久久| 伊人久久五月丁香综合中文亚洲| 人妻视频一区二区三区免费| 亚洲午夜精品久久久久久app| 免费观看的av毛片的网站| 人妻无码中文字幕免费视频蜜桃| 亚洲精品无码成人片在线观看 | 国产亚洲高清不卡在线观看| 成全动漫视频在线观看免费高清版下载| 亚洲国产精品一区二区久久hs | 久久青草91免费观看| 在线观看亚洲人成网站| 永久免费AV无码国产网站| jizzjizz亚洲日本少妇| 国产午夜亚洲不卡| 久久久久久精品成人免费图片| 亚洲日韩国产一区二区三区在线| 一本色道久久88亚洲综合| 花蝴蝶免费视频在线观看高清版| 中文字幕在线观看亚洲| 日本免费人成视频播放| 两个人日本免费完整版在线观看1 两个人的视频www免费 | 亚洲夂夂婷婷色拍WW47| 亚洲欧洲国产成人综合在线观看 | 免费精品国偷自产在线在线| 黄色毛片视频免费| 亚洲高清中文字幕综合网| 免费涩涩在线视频网| 久久免费线看线看| 亚洲国产aⅴ成人精品无吗| 国产亚洲AV手机在线观看| 最新猫咪www免费人成|