FileUtils.java 1.09 KB
package isa.qa.utils;

import java.io.File;

/**
 *  File utils
 *
 *  @author    May
 *  @date      2018/12/28 16:00
 *  @version   1.0
 */
public class FileUtils {

    /**
     * File suffix separator
     */
    private static final String FILE_SUFFIX_SEPARATOR = ".";

    /**
     * Get file suffix
     *
     * @param fileName file name
     * @return file suffix
     */
    public static String getFileSuffix(String fileName) {
        return fileName.substring(fileName.lastIndexOf("."));
    }


    /**
     * Make directory
     *
     * @param dirPath dir's path
     * @return mkdir result
     */
    public static boolean mkdir(String dirPath) {
        File file = new File(dirPath);

        if (!file.exists()) {
            return file.mkdirs();
        }

        return true;
    }

    /**
     * Delete the file
     *
     * @param filePath file's path
     * @return delete file result
     */
    public static boolean delFile(String filePath) {
        File file = new File(filePath);

        if (file.exists()) {
            return file.delete();
        }

        return true;
    }
}