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
31 lines (22 loc) · 1.25 KB
/
Main.java
File metadata and controls
31 lines (22 loc) · 1.25 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
30
31
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 customFilePrefix = "log_";
String customFileSuffix = ".txt";
System.out.println("Custom temporary base dir: " + customBaseDir);
Path tmpNoPrefixSuffix = Files.createTempFile(null, null);
System.out.println("Created as (default location, no prefix and suffix): " + tmpNoPrefixSuffix);
Path tmpCustomPrefixAndSuffix = Files.createTempFile(customFilePrefix, customFileSuffix);
System.out.println("Created as (default location, custom prefix and suffix): " + tmpCustomPrefixAndSuffix);
Path tmpCustomLocationPrefixSuffix = Files.createTempFile(
customBaseDir, customFilePrefix, customFileSuffix);
System.out.println("Created as (custom location, prefix and suffix): " + tmpCustomLocationPrefixSuffix);
}
}