com.sun.enterprise.util.io.FileUtils.deleteFile()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中com.sun.enterprise.util.io.FileUtils.deleteFile()方法的一些代码示例,展示了FileUtils.deleteFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.deleteFile()方法的具体详情如下:
包路径:com.sun.enterprise.util.io.FileUtils
类名称:FileUtils
方法名:deleteFile

FileUtils.deleteFile介绍

[英]Delete a file. If on Windows and the delete fails, run the gc and retry the deletion.
[中]删除一个文件。如果在Windows上删除失败,请运行gc并重试删除。

代码示例

代码示例来源:origin: eclipse-ee4j/glassfish

/**
 * Delete a file.  If impossible to delete then try to delete it when the JVM exits.
 * E.g. when Windows is using a jar in the current JVM -- you can not delete the jar until
 * the JVM dies.
 * @param f file to delete
 */
public static void deleteFileNowOrLater(File f) {
  if(!deleteFile(f))
    f.deleteOnExit();
}

代码示例来源:origin: org.glassfish.main.common/common-util

/**
 * Delete a file.  If impossible to delete then try to delete it when the JVM exits.
 * E.g. when Windows is using a jar in the current JVM -- you can not delete the jar until
 * the JVM dies.
 * @param f file to delete
 */
public static void deleteFileNowOrLater(File f) {
  if(!deleteFile(f))
    f.deleteOnExit();
}

代码示例来源:origin: org.glassfish.deployment/deployment-common

/**
 * Deletes the underlying jar file
 */
public boolean delete() {
  File f = new File(uri);
  if (f.exists()) {
    return FileUtils.deleteFile(f);
  }
  return false;
}

代码示例来源:origin: org.glassfish.deployment/deployment-common

/**
 * deletes the underlying jar file
 */
public boolean delete() {
  if (jarFile==null) {
    return false;
  }
  try {
    jarFile.close();
    jarFile = null;
  } catch (IOException ioe) {
    return false;
  }
  return FileUtils.deleteFile(new File(uri));
}

代码示例来源:origin: org.glassfish.main.deployment/deployment-autodeploy

private void cleanupAppAndRequest(File f) {
  boolean logFine = deplLogger.isLoggable(Level.FINE);
  /*
   * Clean up the application file or directory.
   */
  if (f.isDirectory()) {
    if (logFine) {
      deplLogger.fine("Deleting autodeployed directory " + f.getAbsolutePath() + " by request");
    }
    FileUtils.liquidate(f);
  } else {
    if (logFine) {
      deplLogger.fine("Deleting autodeployed file " + f.getAbsolutePath() + " by request");
    }
    FileUtils.deleteFile(f);
  }
  
  /*
   * Remove the undeploy request file.
   */
  File requestFile = AutoDeployedFilesManager.appToUndeployRequestFile(f);
  if (logFine) {
    deplLogger.fine("Deleting autodeploy request file " + requestFile.getAbsolutePath());
  }
  FileUtils.deleteFile(requestFile);
}

代码示例来源:origin: org.glassfish.deployment/deployment-common

/**
 * utility method for deleting a directory and all its content
 */
private boolean deleteDir(File directory) throws IOException {
  if (!directory.isDirectory()) {
    throw new FileNotFoundException(directory.getPath());
  }
  boolean allDeletesSucceeded = true;
  // delete contents
  File[] entries = directory.listFiles();
  for (int i=0;i<entries.length;i++) {
    if (entries[i].isDirectory()) {
      allDeletesSucceeded &= deleteDir(entries[i]);
    } else {
      if ( ! entries[i].equals(StaleFileManager.Util.markerFile(archive))) {
        final boolean fileDeleteOK = FileUtils.deleteFile(entries[i]);
        if (fileDeleteOK) {
          staleFileManager.recordDeletedEntry(entries[i]);
        }
        allDeletesSucceeded &= fileDeleteOK;
      }
    }
  }
  // delete self
  return (allDeletesSucceeded && FileUtils.deleteFile(directory));
}

代码示例来源:origin: org.glassfish.main.admin/server-mgmt

protected void deleteMasterPasswordFile(RepositoryConfig config)
{
  final PEFileLayout layout = getFileLayout(config);
  final File pwdFile = layout.getMasterPasswordFile();    
  FileUtils.deleteFile(pwdFile);
}

代码示例来源:origin: org.glassfish.common/common-util

else if (!deleteFile(f) && undeletedFiles != null) {
      undeletedFiles.add(f);
return deleteFile(parent);

代码示例来源:origin: org.glassfish.main.common/common-util

else if (!deleteFile(f) && undeletedFiles != null) {
      undeletedFiles.add(f);
return deleteFile(parent);

代码示例来源:origin: eclipse-ee4j/glassfish

else if (!deleteFile(f) && undeletedFiles != null) {
      undeletedFiles.add(f);
return deleteFile(parent);

代码示例来源:origin: org.glassfish.main.admin/server-mgmt

/**
   * Changes the master password in the master password file
   * @param saveMasterPassword
   * @param config
   * @param newPassword
   * @throws RepositoryException
   */
  public void changeMasterPasswordInMasterPasswordFile(File pwdFile, String newPassword,
    boolean saveMasterPassword) throws RepositoryException 
  {
      FileUtils.deleteFile(pwdFile);
    if (saveMasterPassword) {
       try {                    
         PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(), 
           getMasterPasswordPassword());
         p.setPasswordForAlias(MASTER_PASSWORD_ALIAS, newPassword.getBytes());
         chmod("600", pwdFile);
       } catch (Exception ex) {                        
         throw new RepositoryException(_strMgr.getString("masterPasswordFileNotCreated", pwdFile),
           ex);
       } 
    }         
  }
}

相关文章