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

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

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

FileUtils.mkdirsMaybe介绍

[英]Wrapper for File.mkdirs This version will return true if the directory exists when the method returns. Unlike File.mkdirs which returns false if the directory already exists.
[中]

代码示例

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

private File getCacheFile(String key) throws IOException{
  File dir = AsadminSecurityUtil.getDefaultClientDir();
  int idx = key.lastIndexOf('/');
  if (idx > 0) {
    dir = new File(dir, key.substring(0, idx));
    if(!FileUtils.mkdirsMaybe(dir))
      throw new IOException("Can't create directory: " + dir);
    key = key.substring(idx + 1);
    if (key.isEmpty()) {
      key = DEFAULT_FILENAME;
    }
  }
  return new File(dir, key);
}

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

/**
 * Copies a file.
 *
 * @param fin  File to copy
 * @param fout New file
 * @throws IOException if an error while copying the content
 */
public static void copy(File fin, File fout) throws IOException {
  if (safeIsDirectory(fin)) {
    copyTree(fin, fout);
    return;
  }
  if (!fin.exists())
    throw new IllegalArgumentException("File source doesn't exist");
    if(!mkdirsMaybe(fout.getParentFile()))
      throw new RuntimeException("Can't create parent dir of output file: " + fout);
  copyFile(fin, fout);
}

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

bis = new BufferedInputStream(is);
if(!mkdirsMaybe(f.getParentFile()))
  throw new RuntimeException("Can't create parent dir of output file: " + f);

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

bis = new BufferedInputStream(is);
if(!mkdirsMaybe(f.getParentFile()))
  throw new RuntimeException("Can't create parent dir of output file: " + f);

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

/**
 * Copies a file.
 *
 * @param fin  File to copy
 * @param fout New file
 * @throws IOException if an error while copying the content
 */
public static void copy(File fin, File fout) throws IOException {
  if (safeIsDirectory(fin)) {
    copyTree(fin, fout);
    return;
  }
  if (!fin.exists())
    throw new IllegalArgumentException("File source doesn't exist");
    if(!mkdirsMaybe(fout.getParentFile()))
      throw new RuntimeException("Can't create parent dir of output file: " + fout);
  copyFile(fin, fout);
}

代码示例来源:origin: org.glassfish.main.admin/launcher

private void setupInstallationDir() throws GFLauncherException {
  String err = "You must set the environmental variable S1AS_HOME to point " +
      "at a GlassFish installation or at an empty directory or at a " +
      "location where an empty directory can be created.";
  String installDirName = System.getenv(INSTALL_HOME);
  if (!ok(installDirName))
    throw new GFLauncherException(err);
  installDir = new File(installDirName);
  if(!FileUtils.mkdirsMaybe(installDir))
    throw new GFLauncherException(err);
  installDir = SmartFile.sanitize(installDir);
}

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

LogFacade.VALIDATION_ERROR_JAR_PATH, jarEntry2.getName(), ioe));
if (!FileUtils.mkdirsMaybe(resourceFile.getParentFile())) {
  logger.log(Level.WARNING,
      LogFacade.UNABLE_TO_CREATE,

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

/**
 * Copies the entire tree to a new location.
 *
 * @param din  File pointing at root of tree to copy
 * @param dout File pointing at root of new tree
 * @throws IOException if an error while copying the content
 */
public static void copyTree(File din, File dout)
    throws IOException {
  if (!safeIsDirectory(din))
    throw new IllegalArgumentException("Source isn't a directory");
  if(!mkdirsMaybe(dout))
    throw new IllegalArgumentException("Can't create destination directory");
  FileListerRelative flr = new FileListerRelative(din);
  String[] files = flr.getFiles();
  for (int i = 0; i < files.length; i++) {
    File fin = new File(din, files[i]);
    File fout = new File(dout, files[i]);
    copy(fin, fout);
  }
}

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

/**
 * Copies the entire tree to a new location.
 *
 * @param din  File pointing at root of tree to copy
 * @param dout File pointing at root of new tree
 * @throws IOException if an error while copying the content
 */
public static void copyTree(File din, File dout)
    throws IOException {
  if (!safeIsDirectory(din))
    throw new IllegalArgumentException("Source isn't a directory");
  if(!mkdirsMaybe(dout))
    throw new IllegalArgumentException("Can't create destination directory");
  FileListerRelative flr = new FileListerRelative(din);
  String[] files = flr.getFiles();
  for (int i = 0; i < files.length; i++) {
    File fin = new File(din, files[i]);
    File fout = new File(dout, files[i]);
    copy(fin, fout);
  }
}

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

final File mqVarHome = layout.getImqVarHome();
try {
  FileUtils.mkdirsMaybe(mqVarHome);
  final List<String> cmdInput = new ArrayList<String>();
  cmdInput.add(broker.getAbsolutePath());

代码示例来源:origin: org.glassfish.main.admin/launcher

private void setupDomainDir() throws GFLauncherException {
  String domainDirName = getInfo().getDomainName();
  domainDir = getInfo().getDomainParentDir();
  domainDir = new File(domainDir, domainDirName);
  if (!FileUtils.mkdirsMaybe(domainDir))
    throw new GFLauncherException("Can not create directory: " + domainDir);
  domainDir = SmartFile.sanitize(domainDir);
}

代码示例来源:origin: org.glassfish.main.flashlight/flashlight-framework

if (FileUtils.mkdirsMaybe(file.getParentFile())) {
  fos = new FileOutputStream(file);
  fos.write(classData);

相关文章