sp; }
/**
* 不覆盖的创建文件
*
* @param f
*/
public static void createFile(String fileName) {
createFile(fileName, false);
}
/**
* 创建文件
*
* @param fileName
* 创建文件
* @param override
* 是否覆盖
*/
public static void createFile(String fileName, boolean override) {
createFile(newFile(fileName), override);
}
/**
* 检测文件对象是否存在
*
* @param f
*/
public static boolean exists(File f) {
return f.exists() ? true : false;
}
/**
* 检测路径是否存在
*
* @param f
*/
public static boolean exists(String fileName) {
return exists(new File(fileName));
}
/**
* 检测文件对象是否目录
*
* @param f
*/
public static boolean isDirectory(File f) {
return f.isDirectory();
}
/**
* 检测路径是否目录
*
* @param f
*/
public static boolean isDirectory(String fileName) {
return isDirectory(newFile(fileName));
}
/**
* 检测文件对象是否文件
*
* @param f
*/
public static boolean isFile(File f) {
return f.isFile();
}
/**
* 获取文件的后缀名
*
* @param fileName
* @return
*/
public static String suffixName(String fileName) {
return suffixName(newFile(fileName));
}
/**
* 获取不带后缀名的文件名字符串
*
* @param fileName
* @return
*/
public static String getNoSuffixName(String fileName) {
return getNoSuffixName(newFile(fileName));
}
/**
* 获取不带后缀名的文件名字符串
*
* @param f
* @return
*/
public static String getNoSuffixName(File f) {
return f.getName().substring(0, f.getName().lastIndexOf("."));
}
/**
* 重命名
*
* @param fileName1
* 路径
* @param fileName2
* 路径
*/
public static void rename(String fileName1, String fileName2) {
rename(newFile(fileName1), newFile(fileName2));
}
/**
* 重命名
*
* @param f1
* @param f2
*/
public static void rename(File f1, File f2) {
f1.renameTo(f2);
}
/**
* 修改指定路径的文件后缀名。
*
* @param fileName