本文整理了Java中org.scijava.util.FileUtils.createTemporaryDirectory()
方法的一些代码示例,展示了FileUtils.createTemporaryDirectory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.createTemporaryDirectory()
方法的具体详情如下:
包路径:org.scijava.util.FileUtils
类名称:FileUtils
方法名:createTemporaryDirectory
[英]Creates a temporary directory.
Since there is no atomic operation to do that, we create a temporary file, delete it and create a directory in its place. To avoid race conditions, we use the optimistic approach: if the directory cannot be created, we try to obtain a new temporary file rather than erroring out.
It is the caller's responsibility to make sure that the directory is deleted; see #deleteRecursively(File).
[中]创建一个临时目录。
因为没有原子操作可以做到这一点,所以我们创建一个临时文件,删除它并在其位置创建一个目录。为了避免竞争条件,我们使用乐观的方法:如果无法创建目录,我们将尝试获取一个新的临时文件,而不是出错。
调用者有责任确保目录被删除;请参阅#递归删除(文件)。
代码示例来源:origin: org.scijava/scijava-common
/**
* Creates a temporary directory.
* <p>
* Since there is no atomic operation to do that, we create a temporary file,
* delete it and create a directory in its place. To avoid race conditions, we
* use the optimistic approach: if the directory cannot be created, we try to
* obtain a new temporary file rather than erroring out.
* </p>
* <p>
* It is the caller's responsibility to make sure that the directory is
* deleted; see {@link #deleteRecursively(File)}.
* </p>
*
* @param prefix The prefix string to be used in generating the file's name;
* see {@link File#createTempFile(String, String, File)}
* @return An abstract pathname denoting a newly-created empty directory
* @throws IOException
*/
public static File createTemporaryDirectory(final String prefix)
throws IOException
{
return createTemporaryDirectory(prefix, null, null);
}
代码示例来源:origin: scijava/scijava-common
/**
* Creates a temporary directory.
* <p>
* Since there is no atomic operation to do that, we create a temporary file,
* delete it and create a directory in its place. To avoid race conditions, we
* use the optimistic approach: if the directory cannot be created, we try to
* obtain a new temporary file rather than erroring out.
* </p>
* <p>
* It is the caller's responsibility to make sure that the directory is
* deleted; see {@link #deleteRecursively(File)}.
* </p>
*
* @param prefix The prefix string to be used in generating the file's name;
* see {@link File#createTempFile(String, String, File)}
* @return An abstract pathname denoting a newly-created empty directory
* @throws IOException
*/
public static File createTemporaryDirectory(final String prefix)
throws IOException
{
return createTemporaryDirectory(prefix, null, null);
}
代码示例来源:origin: org.scijava/scijava-common
/**
* Creates a temporary directory.
* <p>
* Since there is no atomic operation to do that, we create a temporary file,
* delete it and create a directory in its place. To avoid race conditions, we
* use the optimistic approach: if the directory cannot be created, we try to
* obtain a new temporary file rather than erroring out.
* </p>
* <p>
* It is the caller's responsibility to make sure that the directory is
* deleted; see {@link #deleteRecursively(File)}.
* </p>
*
* @param prefix The prefix string to be used in generating the file's name;
* see {@link File#createTempFile(String, String, File)}
* @param suffix The suffix string to be used in generating the file's name;
* see {@link File#createTempFile(String, String, File)}
* @return An abstract pathname denoting a newly-created empty directory
* @throws IOException
*/
public static File createTemporaryDirectory(final String prefix,
final String suffix) throws IOException
{
return createTemporaryDirectory(prefix, suffix, null);
}
代码示例来源:origin: scijava/scijava-common
/**
* Creates a temporary directory.
* <p>
* Since there is no atomic operation to do that, we create a temporary file,
* delete it and create a directory in its place. To avoid race conditions, we
* use the optimistic approach: if the directory cannot be created, we try to
* obtain a new temporary file rather than erroring out.
* </p>
* <p>
* It is the caller's responsibility to make sure that the directory is
* deleted; see {@link #deleteRecursively(File)}.
* </p>
*
* @param prefix The prefix string to be used in generating the file's name;
* see {@link File#createTempFile(String, String, File)}
* @param suffix The suffix string to be used in generating the file's name;
* see {@link File#createTempFile(String, String, File)}
* @return An abstract pathname denoting a newly-created empty directory
* @throws IOException
*/
public static File createTemporaryDirectory(final String prefix,
final String suffix) throws IOException
{
return createTemporaryDirectory(prefix, suffix, null);
}
代码示例来源:origin: scijava/scijava-jupyter-kernel
@Override
public Path getTempFolder() {
log.debug("getTempFolder()");
try {
return FileUtils.createTemporaryDirectory("scijava-jupyter-kernel", null).toPath();
}
catch (final IOException exc) {
throw new RuntimeException(exc);
}
}
代码示例来源:origin: org.scijava/scripting-java
TransformerFactoryConfigurationError
final File directory = FileUtils.createTemporaryDirectory("java", "");
final File file = new File(directory, ".java");
内容来源于网络,如有侵权,请联系作者删除!