本文整理了Java中java.nio.file.Files.createTempDirectory()
方法的一些代码示例,展示了Files.createTempDirectory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Files.createTempDirectory()
方法的具体详情如下:
包路径:java.nio.file.Files
类名称:Files
方法名:createTempDirectory
暂无
代码示例来源:origin: skylot/jadx
public static File createTempDir(String suffix) {
try {
Path path = Files.createTempDirectory("jadx-tmp-" + System.nanoTime() + "-" + suffix);
path.toFile().deleteOnExit();
return path.toFile();
} catch (IOException e) {
throw new JadxRuntimeException("Failed to create temp directory with suffix: " + suffix);
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Create a temporary directory for GenIC output.
*
* @return the temp directory.
* @throws BuildException if a temp directory cannot be created.
*/
private File createTempDir() throws IOException {
return Files.createTempDirectory("genic").toFile();
}
代码示例来源:origin: SonarSource/sonarqube
public File createTempDir() {
try {
return Files.createTempDirectory(tempDir.toPath(), "plugins").toFile();
} catch (IOException e) {
throw new IllegalStateException("Fail to create temp directory in " + tempDir, e);
}
}
代码示例来源:origin: eclipse-vertx/vert.x
public String perform() {
try {
Path tmpDir;
if (parentDir != null) {
Path dir = vertx.resolveFile(parentDir).toPath();
if (attrs != null) {
tmpDir = Files.createTempDirectory(dir, prefix, attrs);
} else {
tmpDir = Files.createTempDirectory(dir, prefix);
}
} else {
if (attrs != null) {
tmpDir = Files.createTempDirectory(prefix, attrs);
} else {
tmpDir = Files.createTempDirectory(prefix);
}
}
return tmpDir.toFile().getAbsolutePath();
} catch (IOException e) {
throw new FileSystemException(e);
}
}
};
代码示例来源:origin: apache/incubator-pinot
@VisibleForTesting
public File v3ConversionTempDirectory(File v2SegmentDirectory)
throws IOException {
File v3TempDirectory =
Files.createTempDirectory(v2SegmentDirectory.toPath(), v2SegmentDirectory.getName() + V3_TEMP_DIR_SUFFIX)
.toFile();
return v3TempDirectory;
}
代码示例来源:origin: testcontainers/testcontainers-java
private File createTempDirectory() {
try {
if (SystemUtils.IS_OS_MAC) {
return Files.createTempDirectory(Paths.get(OS_MAC_TMP_DIR), TESTCONTAINERS_TMP_DIR_PREFIX).toFile();
}
return Files.createTempDirectory(TESTCONTAINERS_TMP_DIR_PREFIX).toFile();
} catch (IOException e) {
return new File(TESTCONTAINERS_TMP_DIR_PREFIX + Base58.randomString(5));
}
}
代码示例来源:origin: GoogleContainerTools/jib
Path getApplicationLayersCacheDirectory() throws CacheDirectoryCreationException {
if (applicationLayersCacheDirectory == null) {
// Uses a temporary directory if application layers cache directory is not set.
try {
Path temporaryDirectory = Files.createTempDirectory(null);
temporaryDirectory.toFile().deleteOnExit();
this.applicationLayersCacheDirectory = temporaryDirectory;
} catch (IOException ex) {
throw new CacheDirectoryCreationException(ex);
}
}
return applicationLayersCacheDirectory;
}
代码示例来源:origin: jenkinsci/jenkins
private File createDirectoryForNewUser(String userId) throws IOException {
try {
Path tempDirectory = Files.createTempDirectory(Util.fileToPath(usersDirectory), generatePrefix(userId));
return tempDirectory.toFile();
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Error creating directory for user: " + userId, e);
throw e;
}
}
代码示例来源:origin: rapidoid/rapidoid
public static String createTempDir(String name) {
Path tmpDir;
try {
tmpDir = Files.createTempDirectory(name);
} catch (IOException e) {
throw new RuntimeException("Couldn't create temporary directory!", e);
}
String tmpPath = tmpDir.toAbsolutePath().toString();
tmpDir.toFile().deleteOnExit();
return tmpPath;
}
代码示例来源:origin: apache/geode
public void startFile(String memberId) throws IOException {
if (currentFile != null || currentOutputStream != null) {
throw new IllegalStateException("Cannot open more than one file at once");
}
currentFile = Files.createTempDirectory(memberId).resolve(memberId + ".zip");
currentOutputStream = new BufferedOutputStream(new FileOutputStream(currentFile.toFile()));
isEmpty = true;
}
代码示例来源:origin: apache/geode
public static Path createSecuredTempDirectory(String prefix) throws IOException {
Path tempDir = Files.createTempDirectory(prefix);
tempDir.toFile().setExecutable(true, true);
tempDir.toFile().setWritable(true, true);
tempDir.toFile().setReadable(true, true);
return tempDir;
}
}
代码示例来源:origin: CalebFenton/simplify
private static File disassemble(File file) throws IOException {
Path tempDir = Files.createTempDirectory(TEMP_DIR_NAME);
String[] args = new String[]{"disassemble", "--use-locals", "--sequential-labels", "--code-offsets", file.getAbsolutePath(),
"--output", tempDir.toString(),};
org.jf.baksmali.Main.main(args);
return tempDir.toFile();
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Creates a new temporary directory.
*/
public static File createTempDir() throws IOException {
// The previously used approach of creating a temporary file, deleting
// it, and making a new directory having the same name in its place is
// potentially problematic:
// https://stackoverflow.com/questions/617414/how-to-create-a-temporary-directory-folder-in-java
// We can use the Java 7 Files.createTempDirectory() API, but note that
// by default, the permissions of the created directory are 0700&(~umask)
// whereas the old approach created a temporary directory with permissions
// 0777&(~umask).
// To avoid permissions problems like https://issues.jenkins-ci.org/browse/JENKINS-48407
// we can pass POSIX file permissions as an attribute (see, for example,
// https://github.com/jenkinsci/jenkins/pull/3161 )
final Path tempPath;
final String tempDirNamePrefix = "jenkins";
if (FileSystems.getDefault().supportedFileAttributeViews().contains("posix")) {
tempPath = Files.createTempDirectory(tempDirNamePrefix,
PosixFilePermissions.asFileAttribute(EnumSet.allOf(PosixFilePermission.class)));
} else {
tempPath = Files.createTempDirectory(tempDirNamePrefix);
}
return tempPath.toFile();
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public String invoke(File dir, VirtualChannel channel) throws IOException {
Path tempPath;
final boolean isPosix = FileSystems.getDefault().supportedFileAttributeViews().contains("posix");
if (isPosix) {
tempPath = Files.createTempDirectory(Util.fileToPath(dir), name,
PosixFilePermissions.asFileAttribute(EnumSet.allOf(PosixFilePermission.class)));
} else {
tempPath = Files.createTempDirectory(Util.fileToPath(dir), name, new FileAttribute<?>[] {});
}
if (tempPath.toFile() == null) {
throw new IOException("Failed to obtain file from path " + dir + " on " + remote);
}
return tempPath.toFile().getName();
}
}
代码示例来源:origin: prestodb/presto
@SuppressWarnings("SameParameterValue")
private static File createTempDir(String prefix)
{
try {
return createTempDirectory(prefix).toFile();
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
代码示例来源:origin: neo4j/neo4j
public static File createTempDir() throws IOException
{
return Files.createTempDirectory( "neo4j-test" ).toFile();
}
代码示例来源:origin: oracle/opengrok
private File createTemporaryDirectory(String name) throws IOException {
File f = Files.createTempDirectory(name).toFile();
tempDirs.add(f);
return f;
}
}
代码示例来源:origin: oracle/opengrok
private static File createTemporaryDirectory(String name)
throws IOException {
File f = Files.createTempDirectory(name).toFile();
TEMP_DIRS.add(f);
return f;
}
}
代码示例来源:origin: web3j/web3j
static File createTempDir() throws Exception {
return Files.createTempDirectory(
WalletUtilsTest.class.getSimpleName() + "-testkeys").toFile();
}
代码示例来源:origin: twosigma/beakerx
@Override
public Path createTempFolder() {
Path path;
try {
path = Files.createTempDirectory(EvaluatorBaseTest.TEMP_DIR_NAME);
path.toFile().deleteOnExit();
} catch (Exception e) {
throw new RuntimeException(e);
}
return path;
}
};
内容来源于网络,如有侵权,请联系作者删除!