forked from PacktPublishing/Java-Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
29 lines (20 loc) · 1.08 KB
/
Copy pathMain.java
File metadata and controls
29 lines (20 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package modern.challenge;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
public class Main {
public static void main(String[] args) throws IOException {
String defaultBaseDir = System.getProperty("java.io.tmpdir");
System.out.println("Default temporary base dir: " + defaultBaseDir);
Path customBaseDir = FileSystems.getDefault().getPath("D:/tmp");
String customDirPrefix = "logs_";
System.out.println("Custom temporary base dir: " + customBaseDir);
Path tmpNoPrefix = Files.createTempDirectory(null);
System.out.println("Created as (default location, no prefix): " + tmpNoPrefix);
Path tmpCustomPrefix = Files.createTempDirectory(customDirPrefix);
System.out.println("Created as (default location and custom prefix): " + tmpCustomPrefix);
Path tmpCustomLocationAndPrefix = Files.createTempDirectory(customBaseDir, customDirPrefix);
System.out.println("Created as (custom location and prefix): " + tmpCustomLocationAndPrefix);
}
}