Java Code Examples for jodd.io.FileUtil#delete()

The following examples show how to use jodd.io.FileUtil#delete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileDeleteTest.java    From ueboot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void delete(File file) throws IOException {
    String fileName = file.getName();
    if(file.isDirectory()&&(fileName.equals(".settings")
            || fileName.equals("target"))){
        FileUtil.delete(file);
        System.out.println("删除文件夹"+file.getAbsolutePath()+fileName);
    }else if(file.isFile() && (fileName.equals(".classpath")
            || fileName.equals(".project") || fileName.equals(".gitignore"))
    ){
        file.delete();
        System.out.println("删除文件"+file.getAbsolutePath()+fileName);
    }
    File[] files = file.listFiles();
    if(files == null){
        return;
    }
    for (int i = 0; i < files.length; i++) {
        File f = files[i];
        this.delete(f);
    }
}
 
Example 2
Source File: SysToolkit.java    From DAFramework with MIT License 5 votes vote down vote up
public static void delFiles(String file) throws Exception {
	File f = new File(polishFilePath(file));
	if (f.exists()) {
		LOG.info("删除" + file);
		if (f.isDirectory()) {
			if (isSymbolicLink(file)) {
				exec("rd /q " + f.getAbsolutePath() + "", ".", true, true);
			} else {
				FileUtil.deleteDir(f.getAbsolutePath(), new FileUtilParams().setRecursive(true).setContinueOnError(false));
			}
		} else {
			FileUtil.delete(f.getAbsolutePath(), new FileUtilParams().setContinueOnError(false));
		}
	}
}
 
Example 3
Source File: SysToolkit.java    From wES with MIT License 5 votes vote down vote up
public static void delFiles(String file) throws Exception {
	File f = new File(polishFilePath(file));
	if (f.exists()) {
		LOG.info("删除" + file);
		if (f.isDirectory()) {
			if (isSymbolicLink(file)) {
				exec("rd /q " + f.getAbsolutePath() + "", ".", true, true);
			} else {
				FileUtil.deleteDir(f.getAbsolutePath(), new FileUtilParams().setRecursive(true).setContinueOnError(false));
			}
		} else {
			FileUtil.delete(f.getAbsolutePath(), new FileUtilParams().setContinueOnError(false));
		}
	}
}