亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? fileutils.java

?? < JavaME核心技術最佳實踐>>的全部源代碼
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:

    //-----------------------------------------------------------------------
    /**
     * Writes a String to a file creating the file if it does not exist.
     * <p>
     * There is no writeStringToFile method without encoding parameter because
     * the default encoding can differ between platforms and will have
     * inconsistent results.
     *
     * @param file  the file to write
     * @param data  the content to write to the file
     * @param encoding  the encoding to use, null means platform default
     * @throws IOException in case of an I/O error
     * @throws UnsupportedEncodingException if the encoding is not supported by the VM
     */
    public static void writeStringToFile(File file,
            String data, String encoding) throws IOException {
        OutputStream out = new FileOutputStream(file);
        try {
            IOUtils.write(data, out, encoding);
        } finally {
            IOUtils.closeQuietly(out);
        }
    }

    /**
     * Writes a byte array to a file creating the file if it does not exist.
     *
     * @param file  the file to write to
     * @param data  the content to write to the file
     * @throws IOException in case of an I/O error
     * @since Commons IO 1.1
     */
    public static void writeByteArrayToFile(
            File file, byte[] data) throws IOException {
        OutputStream out = new FileOutputStream(file);
        try {
            out.write(data);
        } finally {
            IOUtils.closeQuietly(out);
        }
    }

    /**
     * Writes the <code>toString()</code> value of each item in a collection to
     * the specified <code>File</code> line by line.
     * The specified character encoding and the default line ending will be used.
     * <p>
     * There is no writeLines method without encoding parameter because
     * the default encoding can differ between platforms and will have
     * inconsistent results.
     *
     * @param file  the file to write to
     * @param encoding  the encoding to use, null means platform default
     * @param lines  the lines to write, null entries produce blank lines
     * @throws IOException in case of an I/O error
     * @throws UnsupportedEncodingException if the encoding is not supported by the VM
     * @since Commons IO 1.1
     */
    public static void writeLines(File file, String encoding, Collection lines) throws IOException {
        writeLines(file, encoding, lines, null);
    }

    /**
     * Writes the <code>toString()</code> value of each item in a collection to
     * the specified <code>File</code> line by line.
     * The specified character encoding and the line ending will be used.
     * <p>
     * There is no writeLines method without encoding parameter because
     * the default encoding can differ between platforms and will have
     * inconsistent results.
     *
     * @param file  the file to write to
     * @param encoding  the encoding to use, null means platform default
     * @param lines  the lines to write, null entries produce blank lines
     * @param lineEnding  the line separator to use, null is system default
     * @throws IOException in case of an I/O error
     * @throws UnsupportedEncodingException if the encoding is not supported by the VM
     * @since Commons IO 1.1
     */
    public static void writeLines(File file, String encoding, Collection lines, String lineEnding) throws IOException {
        OutputStream out = new FileOutputStream(file);
        try {
            IOUtils.writeLines(lines, lineEnding, out, encoding);
        } finally {
            IOUtils.closeQuietly(out);
        }
    }

    //-----------------------------------------------------------------------
    /**
     * Delete a file. If file is a directory, delete it and all sub-directories.
     * <p>
     * The difference between File.delete() and this method are:
     * <ul>
     * <li>A directory to be deleted does not have to be empty.</li>
     * <li>You get exceptions when a file or directory cannot be deleted.
     *      (java.io.File methods returns a boolean)</li>
     * </ul>
     *
     * @param file  file or directory to delete, not null
     * @throws NullPointerException if the directory is null
     * @throws IOException in case deletion is unsuccessful
     */
    public static void forceDelete(File file) throws IOException {
        if (file.isDirectory()) {
            deleteDirectory(file);
        } else {
            if (!file.exists()) {
                throw new FileNotFoundException("File does not exist: " + file);
            }
            if (!file.delete()) {
                String message =
                    "Unable to delete file: " + file;
                throw new IOException(message);
            }
        }
    }

    /**
     * Schedule a file to be deleted when JVM exits.
     * If file is directory delete it and all sub-directories.
     *
     * @param file  file or directory to delete, not null
     * @throws NullPointerException if the file is null
     * @throws IOException in case deletion is unsuccessful
     */
    public static void forceDeleteOnExit(File file) throws IOException {
        if (file.isDirectory()) {
            deleteDirectoryOnExit(file);
        } else {
            file.deleteOnExit();
        }
    }

    /**
     * Recursively schedule directory for deletion on JVM exit.
     *
     * @param directory  directory to delete, not null
     * @throws NullPointerException if the directory is null
     * @throws IOException in case deletion is unsuccessful
     */
    private static void deleteDirectoryOnExit(File directory) throws IOException {
        if (!directory.exists()) {
            return;
        }

        cleanDirectoryOnExit(directory);
        directory.deleteOnExit();
    }

    /**
     * Clean a directory without deleting it.
     *
     * @param directory  directory to clean, not null
     * @throws NullPointerException if the directory is null
     * @throws IOException in case cleaning is unsuccessful
     */
    private static void cleanDirectoryOnExit(File directory) throws IOException {
        if (!directory.exists()) {
            String message = directory + " does not exist";
            throw new IllegalArgumentException(message);
        }

        if (!directory.isDirectory()) {
            String message = directory + " is not a directory";
            throw new IllegalArgumentException(message);
        }

        File[] files = directory.listFiles();
        if (files == null) {  // null if security restricted
            throw new IOException("Failed to list contents of " + directory);
        }

        IOException exception = null;
        for (int i = 0; i < files.length; i++) {
            File file = files[i];
            try {
                forceDeleteOnExit(file);
            } catch (IOException ioe) {
                exception = ioe;
            }
        }

        if (null != exception) {
            throw exception;
        }
    }

    /**
     * Make a directory, including any necessary but nonexistent parent
     * directories. If there already exists a file with specified name or
     * the directory cannot be created then an exception is thrown.
     *
     * @param directory  directory to create, not null
     * @throws NullPointerException if the directory is null
     * @throws IOException if the directory cannot be created
     */
    public static void forceMkdir(File directory) throws IOException {
        if (directory.exists()) {
            if (directory.isFile()) {
                String message =
                    "File "
                        + directory
                        + " exists and is "
                        + "not a directory. Unable to create directory.";
                throw new IOException(message);
            }
        } else {
            if (!directory.mkdirs()) {
                String message =
                    "Unable to create directory " + directory;
                throw new IOException(message);
            }
        }
    }

    //-----------------------------------------------------------------------
    /**
     * Recursively count size of a directory (sum of the length of all files).
     *
     * @param directory  directory to inspect, not null
     * @return size of directory in bytes, 0 if directory is security restricted
     * @throws NullPointerException if the directory is null
     */
    public static long sizeOfDirectory(File directory) {
        if (!directory.exists()) {
            String message = directory + " does not exist";
            throw new IllegalArgumentException(message);
        }

        if (!directory.isDirectory()) {
            String message = directory + " is not a directory";
            throw new IllegalArgumentException(message);
        }

        long size = 0;

        File[] files = directory.listFiles();
        if (files == null) {  // null if security restricted
            return 0L;
        }
        for (int i = 0; i < files.length; i++) {
            File file = files[i];

            if (file.isDirectory()) {
                size += sizeOfDirectory(file);
            } else {
                size += file.length();
            }
        }

        return size;
    }

    //-----------------------------------------------------------------------
    /**
     * Tests if the specified <code>File</code> is newer than the reference
     * <code>File</code>.
     *
     * @param file  the <code>File</code> of which the modification date must
     * be compared, not null
     * @param reference  the <code>File</code> of which the modification date
     * is used, not null
     * @return true if the <code>File</code> exists and has been modified more
     * recently than the reference <code>File</code>
     * @throws IllegalArgumentException if the file is null
     * @throws IllegalArgumentException if the reference file is null or doesn't exist
     */
     public static boolean isFileNewer(File file, File reference) {
        if (reference == null) {
            throw new IllegalArgumentException("No specified reference file");
        }
        if (!reference.exists()) {
            throw new IllegalArgumentException("The reference file '"
                    + file + "' doesn't exist");
        }
        return isFileNewer(file, reference.lastModified());
    }

    /**
     * Tests if the specified <code>File</code> is newer than the specified
     * <code>Date</code>.
     * 
     * @param file  the <code>File</code> of which the modification date
     * must be compared, not null
     * @param date  the date reference, not null
     * @return true if the <code>File</code> exists and has been modified
     * after the given <code>Date</code>.
     * @throws IllegalArgumentException if the file is null
     * @throws IllegalArgumentException if the date is null
     */
    public static boolean isFileNewer(File file, Date date) {
        if (date == null) {
            throw new IllegalArgumentException("No specified date");
        }
        return isFileNewer(file, date.getTime());
    }

    /**
     * Tests if the specified <code>File</code> is newer than the specified
     * time reference.
     *
     * @param file  the <code>File</code> of which the modification date must
     * be compared, not null
     * @param timeMillis  the time reference measured in milliseconds since the
     * epoch (00:00:00 GMT, January 1, 1970)
     * @return true if the <code>File</code> exists and has been modified after
     * the given time reference.
     * @throws IllegalArgumentException if the file is null
     */
     public static boolean isFileNewer(File file, long timeMillis) {
        if (file == null) {
            throw new IllegalArgumentException("No specified file");
        }
        if (!file.exists()) {
            return false;
        }
        return file.lastModified() > timeMillis;
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
极品尤物av久久免费看| 美女尤物国产一区| 日本高清不卡在线观看| 亚洲午夜电影在线观看| 久久综合久久鬼色| 欧美日韩国产天堂| 欧美r级在线观看| 午夜精品久久久久久久蜜桃app| 色综合天天做天天爱| 亚洲另类中文字| 在线视频欧美精品| 日本欧美加勒比视频| 亚洲综合色丁香婷婷六月图片| 国产美女在线精品| 色综合久久88色综合天天6| 色婷婷综合久久久中文字幕| 久久久久国产精品麻豆ai换脸 | 国产一区美女在线| 日韩一区二区免费视频| 国产精品一区二区不卡| 成人欧美一区二区三区| 欧美日韩午夜精品| 激情综合五月婷婷| 亚洲男女一区二区三区| 欧美电影免费观看完整版| 99久久综合精品| 激情综合色综合久久综合| 亚洲一二三区视频在线观看| 欧美日韩视频在线第一区| 国产精品乡下勾搭老头1| 亚洲综合在线五月| 日本一区二区三级电影在线观看 | 免费久久99精品国产| 国产综合成人久久大片91| 国产一区二区精品久久| 欧美日韩国产影片| 日本中文在线一区| 久久综合五月天婷婷伊人| 在线视频欧美区| 成人精品视频网站| 成人av网址在线| 午夜成人在线视频| 在线视频亚洲一区| 狠狠v欧美v日韩v亚洲ⅴ| 国产精品久久99| 欧美性高清videossexo| 国产成人免费网站| 亚洲男同性恋视频| 国产精品视频一二三区| 日韩免费看网站| 欧美一卡二卡在线观看| 欧美主播一区二区三区美女| 在线观看91视频| 欧美亚日韩国产aⅴ精品中极品| 成人黄色大片在线观看| 99久久精品免费观看| 国产激情一区二区三区桃花岛亚洲| 久久99精品网久久| 精品一区二区三区蜜桃| 国产91丝袜在线观看| 不卡的av电影在线观看| 色哟哟亚洲精品| 欧美男同性恋视频网站| 精品日产卡一卡二卡麻豆| 91久久久免费一区二区| 欧美精品久久99久久在免费线| 欧美电影一区二区| 欧美成人a视频| 日韩美女啊v在线免费观看| 中文字幕不卡在线播放| 一区二区高清免费观看影视大全| 亚洲成人免费观看| 国产成人精品免费在线| 欧美艳星brazzers| 久久综合资源网| 婷婷丁香久久五月婷婷| 国产一区二区三区免费在线观看| 色综合天天综合在线视频| 欧美日韩一区二区三区视频| 久久亚洲综合av| 亚洲高清一区二区三区| 国产精品中文字幕欧美| 欧美日韩一级片在线观看| 精品国产3级a| 亚洲chinese男男1069| 成+人+亚洲+综合天堂| 日韩一区二区免费高清| 亚洲尤物在线视频观看| 国产乱码一区二区三区| 欧美日韩黄色一区二区| 国产精品视频看| 国产麻豆精品theporn| 日韩一区二区在线观看视频| 亚洲一级二级在线| 97se亚洲国产综合在线| 中文字幕欧美日本乱码一线二线| 国产综合色产在线精品| 精品少妇一区二区三区视频免付费 | 在线成人免费观看| 国产一区二区三区高清播放| 日韩一区二区麻豆国产| 日韩黄色免费电影| 制服丝袜日韩国产| 美脚の诱脚舐め脚责91| 26uuu精品一区二区三区四区在线| 精品国产一区二区三区久久影院| 日韩欧美激情在线| 日韩电影在线看| 日韩视频中午一区| 国产一区二区三区日韩| 欧美国产精品一区| 欧美最新大片在线看| 日本午夜一区二区| 国产日韩三级在线| 91麻豆国产自产在线观看| 午夜免费欧美电影| 久久久久青草大香线综合精品| 波多野结衣欧美| 夜夜嗨av一区二区三区四季av| 在线电影院国产精品| 粉嫩aⅴ一区二区三区四区五区| 亚洲欧美国产高清| 欧美一级欧美一级在线播放| 国产精品综合视频| 午夜精品123| 中文字幕一区二| 精品久久久久久久人人人人传媒| 99在线热播精品免费| 看片网站欧美日韩| 亚洲欧美国产77777| 久久青草国产手机看片福利盒子| a在线欧美一区| 国产老女人精品毛片久久| 一区二区三区精品在线| 中文字幕精品一区二区精品绿巨人 | 麻豆精品在线看| 夜夜亚洲天天久久| 亚洲裸体xxx| 精品久久五月天| 7777精品伊人久久久大香线蕉经典版下载 | 亚洲第一搞黄网站| 亚洲日韩欧美一区二区在线| 久久久久青草大香线综合精品| 日韩亚洲欧美综合| 日韩欧美一区二区不卡| 在线播放中文字幕一区| 欧美日本在线播放| 欧美色视频在线观看| 欧美午夜免费电影| 91福利视频网站| 在线成人av影院| 欧美一级日韩不卡播放免费| 欧美一级二级在线观看| 日韩欧美美女一区二区三区| 久久综合狠狠综合久久综合88 | 成人av综合一区| 粉嫩av一区二区三区| 99久久er热在这里只有精品15| av网站免费线看精品| 91婷婷韩国欧美一区二区| 欧美色中文字幕| 精品久久久久99| 国产精品乱人伦一区二区| 一级日本不卡的影视| 亚洲成av人片在线观看无码| 久久黄色级2电影| 丁香桃色午夜亚洲一区二区三区| 波多野结衣亚洲一区| 欧美日韩在线亚洲一区蜜芽| 日韩欧美一区中文| 日本一区二区电影| 日韩电影免费在线看| 成人激情动漫在线观看| 欧美久久久久久蜜桃| 国产精品视频一二三区| 日本va欧美va瓶| 色婷婷一区二区三区四区| 2017欧美狠狠色| 亚洲一区二区三区三| 99九九99九九九视频精品| 日韩一二三区视频| 亚洲不卡在线观看| 色综合久久中文字幕综合网 | 精品国产一区二区三区不卡 | 日本欧洲一区二区| 91一区二区在线观看| 久久一区二区视频| 日韩中文字幕1| 欧美专区在线观看一区| 中文成人综合网| 国产又粗又猛又爽又黄91精品| 欧美特级限制片免费在线观看| 中文字幕乱码久久午夜不卡 | av电影在线观看一区| 中文字幕高清不卡| 国产成人免费在线观看不卡| 日韩一区二区三免费高清| 免费人成精品欧美精品| 欧美一区二区三区在线看| 偷窥少妇高潮呻吟av久久免费|