本文整理了Java中com.sun.enterprise.util.io.FileUtils.deleteFileMaybe()
方法的一些代码示例,展示了FileUtils.deleteFileMaybe()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.deleteFileMaybe()
方法的具体详情如下:
包路径:com.sun.enterprise.util.io.FileUtils
类名称:FileUtils
方法名:deleteFileMaybe
[英]Wrapper for File.delete This version will return true if the file does not exist when the method returns. Unlike File.delete which returns false if the file does not exist.
[中]文件的包装器。如果方法返回时文件不存在,删除此版本将返回true。不同于文件。delete,如果文件不存在,则返回false。
代码示例来源:origin: org.glassfish.main.web/war-util
/**
* Delete the specified directory, including all of its contents and
* subdirectories recursively.
*
* @param dir File object representing the directory to be deleted
*/
protected static void deleteDir(File dir) {
String files[] = dir.list();
if (files == null) {
files = new String[0];
}
for (int i = 0; i < files.length; i++) {
File file = new File(dir, files[i]);
if (file.isDirectory()) {
deleteDir(file);
} else {
if (!FileUtils.deleteFileMaybe(file)) {
logger.log(Level.WARNING,
LogFacade.UNABLE_TO_DELETE,
file.toString());
}
}
}
if (!FileUtils.deleteFileMaybe(dir)) {
logger.log(Level.WARNING,
LogFacade.UNABLE_TO_DELETE,
dir.toString());
}
}
代码示例来源:origin: org.glassfish.main.admin/admin-util
os.close();
if (!FileUtils.deleteFileMaybe(cacheFile) || !tempFile.renameTo(cacheFile)) {
if (logger.isLoggable(Level.WARNING)) {
logger.log(Level.WARNING, AdminLoggerInfo.mCannotWriteCache,
new Object[] { cacheFile.getPath() });
if(!FileUtils.deleteFileMaybe(tempFile)) {
logger.log(Level.FINE, "can't delete file: {0}", tempFile);
代码示例来源:origin: org.glassfish.main.cluster/cluster-cli
private void restoreInstanceDir() {
File backup = getBackupDir();
if (backup != null && backup.isDirectory()) {
File dir = getServerDirs().getServerDir();
boolean gone = ! FileUtils.deleteFileMaybe(getServerDirs().getServerDir());
if (!gone || !backup.renameTo(dir)) {
logger.warning(Strings.get("import.sync.bundle.restoreInstanceDirFailed", backup.getAbsolutePath(), getServerDirs().getServerDir().getAbsolutePath()));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!