62,616
社区成员
发帖
与我相关
我的任务
分享
/**
* 根据文件(或文件夹)路径,创建文件或文件夹
* @param filePath:文件或文件夹路径* @return:是否成功
*/
public static boolean createFile(String filePath) {
}
package com.wellsoon.ocs.util;
import java.io.File;
/**
* @author 计春旭 E-mail: jichunxu@yahoo.com.cn
* @version 创建时间:Jun 29, 2009 2:51:28 PM
* @see java.lang.Class
* @since JDK1.5
*/
public class makedir {
public static void mkdir(String mkdirName)
{
try
{
File dirFile = new File(mkdirName); //mkdirName为传建文件夹路径
boolean bFile = dirFile.exists();
if( bFile == true )
{
System.out.println("The folder exists.");
}
else
{
System.out.println("The folder do not exist,now trying to create a one...");
bFile = dirFile.mkdir();
if( bFile == true )
{
System.out.println("Create successfully!");
System.out.println("创建文件夹");
}
else
{
System.out.println("Disable to make the folder,please check the disk is full or not.");
System.out.println(" 文件夹创建失败,清确认磁盘没有写保护并且空件足够");
// System.exit(1);
}
}
}
catch(Exception err)
{
System.err.println("ELS - Chart : 文件夹创建发生异常");
err.printStackTrace();
}
}
}