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

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

?? fileutil.java

?? java servlet著名論壇源代碼
?? JAVA
字號:
/*
 * $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/util/FileUtil.java,v 1.14 2004/05/15 19:23:22 minhnn Exp $
 * $Author: minhnn $
 * $Revision: 1.14 $
 * $Date: 2004/05/15 19:23:22 $
 *
 * ====================================================================
 *
 * Copyright (C) 2002-2004 by MyVietnam.net
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * All copyright notices regarding MyVietnam and MyVietnam CoreLib
 * MUST remain intact in the scripts and source code.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Correspondence and Marketing Questions can be sent to:
 * info@MyVietnam.net
 *
 * @author: Minh Nguyen  minhnn@MyVietnam.net
 * @author: Mai  Nguyen  mai.nh@MyVietnam.net
 */
package net.myvietnam.mvncore.util;

import java.io.*;
import java.net.URL;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public final class FileUtil {

    private static Log log = LogFactory.getLog(FileUtil.class);

    private static FileUtil instance = new FileUtil();

    private static String servletClassesPath = null;

    private FileUtil() { // prevent instantiation
    }

    public static void createDir(String dir, boolean ignoreIfExitst) throws IOException {
        File file = new File(dir);

        if (ignoreIfExitst && file.exists()) {
            return;
        }

        if ( file.mkdir() == false) {
            throw new IOException("Cannot create the directory = " + dir);
        }
    }

    public static void createDirs(String dir, boolean ignoreIfExitst) throws IOException {
        File file = new File(dir);

        if (ignoreIfExitst && file.exists()) {
            return;
        }

        if ( file.mkdirs() == false) {
            throw new IOException("Cannot create directories = " + dir);
        }
    }

    public static void deleteFile(String filename) throws IOException {
        File file = new File(filename);
        log.trace("Delete file = " + filename);
        if (file.isDirectory()) {
            throw new IOException("IOException -> BadInputException: not a file.");
        }
        if (file.exists() == false) {
            throw new IOException("IOException -> BadInputException: file is not exist.");
        }
        if (file.delete() == false) {
            throw new IOException("Cannot delete file. filename = " + filename);
        }
    }

    public static void deleteDir(File dir) throws IOException {
        if (dir.isFile()) throw new IOException("IOException -> BadInputException: not a directory.");
        File[] files = dir.listFiles();
        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                File file = files[i];
                if (file.isFile()) {
                    file.delete();
                } else {
                    deleteDir(file);
                }
            }
        }//if
        dir.delete();
    }

    public static long getDirLength(File dir) throws IOException {
        if (dir.isFile()) throw new IOException("BadInputException: not a directory.");
        long size = 0;
        File[] files = dir.listFiles();
        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                File file = files[i];
                long length = 0;
                if (file.isFile()) {
                    length = file.length();
                } else {
                    length = getDirLength(file);
                }
                size += length;
            }//for
        }//if
        return size;
    }

    public static long getDirLength_onDisk(File dir) throws IOException {
        if (dir.isFile()) throw new IOException("BadInputException: not a directory.");
        long size = 0;
        File[] files = dir.listFiles();
        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                File file = files[i];
                long length = 0;
                if (file.isFile()) {
                    length = file.length();
                } else {
                    length = getDirLength_onDisk(file);
                }
                double mod = Math.ceil(((double)length)/512);
                if (mod == 0) mod = 1;
                length = ((long)mod) * 512;
                size += length;
            }
        }//if
        return size;
    }

    public static byte[] getBytes(InputStream inputStream) throws IOException {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(1024);
        byte[] block = new byte[512];
        while (true) {
            int readLength = inputStream.read(block);
            if (readLength == -1) break;// end of file
            byteArrayOutputStream.write(block, 0, readLength);
        }
        byte[] retValue = byteArrayOutputStream.toByteArray();
        byteArrayOutputStream.close();
        return retValue;
    }

    public static String getFileName(String fullFilePath) {
        if (fullFilePath == null) {
            return "";
        }
        int index1 = fullFilePath.lastIndexOf('/');
        int index2 = fullFilePath.lastIndexOf('\\');

        //index is the maximum value of index1 and index2
        int index = (index1 > index2) ? index1 : index2;
        if (index == -1) {
            // not found the path separator
            return fullFilePath;
        }
        String fileName = fullFilePath.substring(index + 1);
        return fileName;
    }

    /**
     * This method could be used to override the path to WEB-INF/classes
     * It can be set when the web app is inited
     * @param path String : new path to override the default path
     */
    public static void setServletClassesPath(String path) {
        log.debug("FileUtil.setServletClassesPath called with path = " + path);

        servletClassesPath = path;
        if (servletClassesPath.endsWith(File.separator) == false) {
            servletClassesPath = servletClassesPath + File.separatorChar;
            log.debug("FileUtil.setServletClassesPath change path to value = " + servletClassesPath);
        }
    }

    /**
     * This function is used to get the classpath of a reference of one class
     * First, this method tries to get the path from system properties
     * named "mvncore.context.path" (can be configed in web.xml). If it cannot
     * find this parameter, then it will tries to load from the ClassLoader
     * @todo FIXME: load from ClassLoader is not correct on Resin/Linux
     */
    public static String getServletClassesPath() {
        if (servletClassesPath == null) {
            String strPath = System.getProperty("mvncore.context.path");
            if (strPath != null && (strPath.length() > 0)) {
                servletClassesPath = strPath;
            } else {
                ClassLoader classLoader = instance.getClass().getClassLoader();
                URL url = classLoader.getResource("/");
                servletClassesPath = url.getPath();
            }
            log.debug("servletClassesPath = " + servletClassesPath);
            if (servletClassesPath.endsWith(File.separator) == false) {
                servletClassesPath = servletClassesPath + File.separatorChar;
                //log.warn("servletClassesPath does not end with /: " + servletClassesPath);
            }
        }
        return servletClassesPath;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产91精品久久久久久久网曝门| 久久99这里只有精品| 色天天综合色天天久久| 国产综合色产在线精品| 日韩电影免费在线看| 亚洲永久精品国产| 亚洲另类在线制服丝袜| 一区二区三区波多野结衣在线观看| 日韩一区中文字幕| 亚洲日本免费电影| 亚洲综合男人的天堂| 亚洲自拍偷拍麻豆| 日韩av一级电影| 老汉av免费一区二区三区| 久久er99热精品一区二区| 经典三级在线一区| 国产69精品久久久久777| 懂色av一区二区三区免费观看| 成人美女在线视频| 91蝌蚪porny| 欧美日韩国产综合一区二区| 欧美精品久久一区| 久久久不卡网国产精品二区 | 成人精品鲁一区一区二区| 五月激情综合婷婷| 国产在线精品不卡| 欧美亚洲一区二区三区四区| 7777精品伊人久久久大香线蕉完整版| 日韩午夜av电影| 国产欧美精品一区二区色综合 | 国产精品你懂的| 亚洲自拍与偷拍| 国产一区二区三区在线观看免费视频| 成人高清视频在线观看| 欧美日韩中文字幕精品| 欧美电视剧免费观看| 国产精品卡一卡二卡三| 午夜精品久久久久久久99水蜜桃 | 一区二区三区免费观看| 日韩av不卡在线观看| 风流少妇一区二区| 欧美日韩亚洲国产综合| 欧美激情综合五月色丁香| 亚洲午夜私人影院| 国产精品69毛片高清亚洲| 在线这里只有精品| 欧美精品一区二区高清在线观看 | 欧美成人免费网站| 一区二区三区四区蜜桃| 国产乱码字幕精品高清av | 一区2区3区在线看| 丝袜美腿亚洲一区二区图片| 大胆亚洲人体视频| 欧美一区二区国产| 亚洲欧洲无码一区二区三区| 美女视频黄频大全不卡视频在线播放| 国产乱理伦片在线观看夜一区| 精品视频色一区| 亚洲人妖av一区二区| 国产精品自在欧美一区| 日韩一区二区在线看| 亚洲自拍偷拍av| 91论坛在线播放| 国产精品少妇自拍| 国产成人免费网站| 26uuuu精品一区二区| 日韩在线卡一卡二| 欧美日韩一区中文字幕| 亚洲精品视频自拍| 精品在线免费观看| 欧美日韩一二三区| 1024成人网| av高清不卡在线| 亚洲精品欧美二区三区中文字幕| 激情图区综合网| 精品粉嫩超白一线天av| 精品一区二区在线免费观看| 日韩一区二区三区视频在线观看| 亚洲成人综合视频| 欧美色电影在线| 香蕉久久夜色精品国产使用方法| 在线观看免费成人| 亚洲va欧美va人人爽| 欧美日韩精品福利| 日韩成人午夜电影| 欧美mv日韩mv| 国产揄拍国内精品对白| 国产日韩视频一区二区三区| 国产精品正在播放| 18成人在线视频| 欧美午夜寂寞影院| av动漫一区二区| 国产高清不卡二三区| 在线日韩一区二区| 91精品国产综合久久精品图片| 1000部国产精品成人观看| 国产一区二区三区国产| 国产三区在线成人av| 大尺度一区二区| 亚洲人成亚洲人成在线观看图片| 91蝌蚪国产九色| 蜜桃视频一区二区三区| 久久香蕉国产线看观看99| 成人av电影在线| 亚洲女人小视频在线观看| 欧美日韩精品福利| 国产乱码一区二区三区| 亚洲精品少妇30p| 欧美精品丝袜中出| 国产宾馆实践打屁股91| 一区二区三区不卡在线观看| 欧美一级国产精品| 91麻豆自制传媒国产之光| 青青草国产成人99久久| 亚洲欧洲日产国码二区| 精品剧情v国产在线观看在线| 成人性生交大片免费看中文网站| 亚洲一区在线播放| 中文字幕亚洲精品在线观看| 欧美精品久久久久久久多人混战| 国产精品中文字幕日韩精品| 亚洲午夜国产一区99re久久| 久久免费精品国产久精品久久久久| 99久久精品国产观看| 免费不卡在线视频| 亚洲精选免费视频| 久久精品一区二区三区不卡| 欧美色图12p| 不卡大黄网站免费看| 久久99精品国产麻豆婷婷| 一区二区三区四区不卡视频| 久久女同性恋中文字幕| 欧美一级搡bbbb搡bbbb| 欧美综合亚洲图片综合区| 国产成人8x视频一区二区| 亚洲尤物在线视频观看| 国产精品久久久久久久久免费桃花 | 亚洲特黄一级片| 欧美一区二区国产| 在线一区二区观看| 成人一区在线看| 国产一区二区不卡| 日本欧美加勒比视频| 亚洲午夜一二三区视频| 国产精品美女久久久久久久网站| 精品国产网站在线观看| 欧美日韩中文字幕一区二区| 777亚洲妇女| 一本大道久久a久久综合婷婷| 不卡视频在线看| 成人性生交大合| 久久国产人妖系列| 青娱乐精品在线视频| 天天影视涩香欲综合网| 香蕉成人伊视频在线观看| 亚洲成在人线免费| 婷婷综合另类小说色区| 午夜精品福利一区二区蜜股av | 99久久婷婷国产综合精品电影 | 中文字幕亚洲欧美在线不卡| 国产欧美日韩视频在线观看| 2023国产精华国产精品| 久久久亚洲高清| 国产视频一区二区在线观看| 久久久精品蜜桃| 国产精品久久精品日日| 日本一区二区成人在线| 一区在线观看视频| 亚洲.国产.中文慕字在线| 丝袜美腿亚洲一区二区图片| 日本成人超碰在线观看| 精品亚洲成a人| 成人免费看视频| 91麻豆视频网站| 欧美精品色一区二区三区| 日韩一二在线观看| 一区二区三区精品久久久| 香蕉加勒比综合久久| 精品无码三级在线观看视频| 国产激情视频一区二区三区欧美| 99综合影院在线| 欧美亚洲综合色| 日韩精品一区二区三区在线| 国产亚洲精品bt天堂精选| 国产精品网站在线| 一区二区不卡在线播放 | 欧美性xxxxxxxx| 欧美日韩一区二区欧美激情| 日韩三级伦理片妻子的秘密按摩| 精品久久久网站| 国产精品久久久久久久久免费相片 | 欧美日韩亚州综合| 精品国产伦一区二区三区观看体验 | 成人av中文字幕| 欧美伊人久久大香线蕉综合69| 正在播放一区二区| 久久精品视频网| 亚洲第一狼人社区| 国产成人精品免费看| 欧美日韩国产一级片|