I am probably overlooking something but what's the right way to create a file Path
from a folder Path
? This is what I'm doing but it seems wrong to convert the folder path to a string just to reconstruct it. Is there a better way?
Path testFolder = Files.createTempDirectory("fileFinder");
Path testFile = Paths.get(testFolder.toString(), "sample.java");
Files.createFile(testFile);
Path testFile = Files.createFile(Files.createTempDirectory("fileFinder").resolve("sample.java"));
但是也许您只需要一个临时文件:
Path testFile = Files.createTempFile("fileFinder");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.