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

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

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

    David.Turing's blog

     

    FileUtils

    /*
    ?*Copyright ? 2006 David.turing
    ?*Email: securex@163.com
    ?*QQ群:14966586
    ?*/
    package org.dev2dev.common;

    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;

    public class FileUtils {
    ??? // 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;
    ??? }
    ???
    ???
    ??? public static void main(String[] args) {

    ??
    ??File x=new File("115.txt");
    ??? try {
    ??FileOutputStream out=new FileOutputStream(x);
    ???? out.write("xxxxxxxxxxxx".getBytes());
    ???? out.flush();
    ???? out.close();
    ?} catch (FileNotFoundException e) {??
    ??e.printStackTrace();
    ?} catch (IOException e) {??
    ??e.printStackTrace();
    ?}
    ???
    ?}

    }

    posted on 2006-05-21 17:16 david.turing 閱讀(659) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     

    導(dǎo)航

    統(tǒng)計(jì)

    常用鏈接

    留言簿(110)

    我參與的團(tuán)隊(duì)

    隨筆分類(126)

    隨筆檔案(155)

    文章分類(9)

    文章檔案(19)

    相冊

    搜索

    積分與排名

    最新隨筆

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 国产一级一毛免费黄片| 亚洲AV日韩AV高潮无码专区| 59pao成国产成视频永久免费| 蜜臀亚洲AV无码精品国产午夜.| 亚洲精品在线播放| 久久精品国产亚洲AV果冻传媒| 免费在线观看日韩| 日韩成全视频观看免费观看高清| 亚洲黄色免费网址| 97av免费视频| 人人揉揉香蕉大免费不卡| 一级毛片**免费看试看20分钟| 色偷偷尼玛图亚洲综合| 国产99在线|亚洲| 亚洲国产视频网站| 亚洲最大黄色网站| 97久久精品亚洲中文字幕无码 | 国产精品亚洲а∨无码播放不卡 | 69av免费观看| 无码免费一区二区三区免费播放| 巨胸喷奶水www永久免费| ssswww日本免费网站片| 成年免费a级毛片| 一个人看的hd免费视频| 成人久久久观看免费毛片| 免费人成网上在线观看| 免费国产在线精品一区| 特级aa**毛片免费观看| 男男gay做爽爽免费视频| 黄色一级视频免费| 五级黄18以上免费看| 一边摸一边桶一边脱免费视频| 免费看黄网站在线看| 丁香六月婷婷精品免费观看| 国产97视频人人做人人爱免费| 国产精品免费大片一区二区| 一级做a爱过程免费视频高清| 国产乱妇高清无乱码免费| 中文字幕免费在线看| 午夜不卡久久精品无码免费 | 97久久精品亚洲中文字幕无码|