<commit_before>package com.keyword.automation.base.utils;

import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;

import org.apache.log4j.Logger;

/**
 * 文件工具类
 * 
 * @author airpy
 *
 */
public class FileUtils {
	private static final Logger log = Logger.getLogger(FileUtils.class);

	/**
	 * 创建目录(若父目录不存在则一并创建)
	 * 
	 * @param dir
	 *            目录
	 */
	public static void mkdir(String dir) {
		try {
			File dirPath = new File(dir);
			if (!dirPath.exists()) {
				dirPath.mkdirs();
			}
		} catch (Exception e) {
			log.error("创建目录[" + dir + "]操作失败: " + e.getMessage());
			e.printStackTrace();
		}
	}

	/**
	 * 新建文件
	 * 
	 * @param fileName
	 *            包含绝对路径的文件名(E:\project\src\123.txt)
	 * @param content
	 *            文件内容
	 */
	public static void createNewFile(String fileName, String content) {
		try {
			File file = new File(fileName);
			deleteFile(fileName);
			file.createNewFile();
			FileWriter fileWriter = new FileWriter(file);
			PrintWriter printWriter = new PrintWriter(fileWriter);
			printWriter.println(content);
			printWriter.flush();
			printWriter.close();
			fileWriter.close();
		} catch (Exception e) {
			log.error("新建文件[" + fileName + "]操作失败: " + e.getMessage());
			e.printStackTrace();
		}
	}

	/**
	 * 删除文件
	 * 
	 * @param fileName
	 *            包含绝对路径的文件名(E:\project\src\123.txt)
	 */
	public static void deleteFile(String fileName) {
		try {
			File file = new File(fileName);
			if (!file.exists()) {
				log.warn("您输入的文件不存在[" + fileName + "]");
				return;
			}
			file.delete();
		} catch (Exception e) {
			log.error("删除文件[" + fileName + "]操作失败: " + e.getMessage());
			e.printStackTrace();
		}
	}
	
	public static void deleteAllFile(String path) {
		File file = new File(path);
		if (!file.exists()) {
			log.error("传入的参数不存在[" + path + "]");
			return;
		}
		if (!file.isDirectory()) {
			log.error("传入的参数为目录[" + path + "]");
			return;
		}
		String[] childFiles = file.list();
		File temp = null;
		for (String tempChild : childFiles) {
			//File.separator与系统有关的默认名称分隔符
            //在UNIX系统上，此字段的值为'/'；在Microsoft Windows系统上，它为 '\'
			if (path.endsWith(File.separator)) {
				temp = new File(path + tempChild);
			} else {
				temp = new File(path + File.separator + tempChild);
			}
			if (temp.isFile()) {
				temp.delete();
			}
			if (temp.isDirectory()) {
				deleteAllFile(path + "/" + childFiles); 
				deleteFolder(path + "/" + childFiles);
			}
		}
	}
	
	public static void deleteFolder(String folderPath) {
		try {
			deleteAllFile(folderPath);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}<commit_msg>modify fileutils<commit_after>package com.keyword.automation.base.utils;

import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;

import org.apache.log4j.Logger;

/**
 * 文件工具类
 * 
 * @author airpy
 *
 */
public class FileUtils {
	private static final Logger log = Logger.getLogger(FileUtils.class);

	/**
	 * 新建目录(若父目录不存在则一并新建)
	 * 
	 * @param dir
	 *            目录
	 */
	public static void makeDirctory(String dir) {
		File dirPath = new File(dir);
		File parentPath = dirPath.getParentFile();
		if (null == dir || dir.isEmpty() || dirPath.exists()) {
			log.warn("参数错误或目录已经存在");
			return;
		}
		try {
			if (null != parentPath && !parentPath.exists()) {
				parentPath.mkdirs();
			}
		} catch (Exception e) {
			log.error("新建目录[" + dir + "]操作失败: " + e.getMessage());
			e.printStackTrace();
		}
	}

	/**
	 * 新建文件
	 * 
	 * @param fileName
	 *            包含绝对路径的文件名(E:\project\src\123.txt)
	 */
	public static void createNewFile(String fileName) {
		try {
			File file = new File(fileName);
			deleteFile(fileName);
			file.createNewFile();
		} catch (Exception e) {
			log.error("新建文件[" + fileName + "]操作失败: " + e.getMessage());
			e.printStackTrace();
		}
	}

	/**
	 * 新建文件
	 * 
	 * @param fileName
	 *            包含绝对路径的文件名(E:\project\src\123.txt)
	 * @param content
	 *            文件内容
	 */
	public static void createNewFile(String fileName, String content) {
		try {
			File file = new File(fileName);
			deleteFile(fileName);
			file.createNewFile();
			FileWriter fileWriter = new FileWriter(file);
			PrintWriter printWriter = new PrintWriter(fileWriter);
			printWriter.println(content);
			printWriter.flush();
			printWriter.close();
			fileWriter.close();
		} catch (Exception e) {
			log.error("新建文件[" + fileName + "]操作失败: " + e.getMessage());
			e.printStackTrace();
		}
	}

	/**
	 * 删除文件
	 * 
	 * @param fileName
	 *            包含绝对路径的文件名(E:\project\src\123.txt)
	 */
	public static void deleteFile(String fileName) {
		try {
			File file = new File(fileName);
			if (!file.exists()) {
				log.warn("您输入的文件不存在[" + fileName + "]");
				return;
			}
			file.delete();
		} catch (Exception e) {
			log.error("删除文件[" + fileName + "]操作失败: " + e.getMessage());
			e.printStackTrace();
		}
	}

	public static void deleteAllFile(String path) {
		File file = new File(path);
		if (!file.exists()) {
			log.error("传入的参数不存在[" + path + "]");
			return;
		}
		if (!file.isDirectory()) {
			log.error("传入的参数为目录[" + path + "]");
			return;
		}
		String[] childFiles = file.list();
		File temp = null;
		for (String tempChild : childFiles) {
			// File.separator与系统有关的默认名称分隔符
			// 在UNIX系统上，此字段的值为'/'；在Microsoft Windows系统上，它为 '\'
			if (path.endsWith(File.separator)) {
				temp = new File(path + tempChild);
			} else {
				temp = new File(path + File.separator + tempChild);
			}
			if (temp.isFile()) {
				temp.delete();
			}
			if (temp.isDirectory()) {
				deleteAllFile(path + "/" + childFiles);
				deleteFolder(path + "/" + childFiles);
			}
		}
	}

	public static void deleteFolder(String folderPath) {
		try {
			deleteAllFile(folderPath);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}
{'fraction_non_alphanumeric': 0.15946322760543744, 'fraction_numerical': 0.0029627047751829907, 'mean_word_length': 2.890847457627119, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '373526', 'n_tokens_mistral': 2436, 'n_tokens_neox': 2208, 'n_words': 401}