com.gagein.util.FileUtils.java Source code

Java tutorial

Introduction

Here is the source code for com.gagein.util.FileUtils.java

Source

//
//                               GageIn, Inc.
//                     Confidential and Proprietary
//                         ALL RIGHTS RESERVED.
//
//      This software is provided under license and may be used
//      or distributed only in accordance with the terms of
//      such license.
//
//
// History: Date        By whom      what
//          Jul 8, 2014     Administrator      Created
//
// CVS version control block - do not edit manually
// $Id: $

package com.gagein.util;

import java.io.File;

import org.apache.log4j.Logger;

public class FileUtils extends org.apache.commons.io.FileUtils {
    /** logger */
    private static final Logger logger = Logger.getLogger(FileUtils.class);

    /**
     * ? url ?????  url ???
     */
    public static String getFileNameByUrl(String url) {
        url = url.substring(7);// remove http://
        url = url.replaceAll("[\\?/:*|<>\"]", "_") + ".html";
        return url;
    }

    public static boolean createDir(String destDirName) {
        File dir = new File(destDirName);
        if (dir.exists()) {
            logger.debug("========" + destDirName + "========?========");
            return true;
        }
        if (!destDirName.endsWith(File.separator)) {
            destDirName = destDirName + File.separator;
        }
        // 
        if (dir.mkdirs()) {
            logger.debug("========" + destDirName + "========??========");
            return true;
        } else {
            logger.debug("========" + destDirName + "========?========");
            return false;
        }
    }
}