2 回答

TA贡献1836条经验 获得超3个赞
我们可以在您的项目中使用许多系统属性。有些列在官方文档中。休息一下,你可以得到一个小片段。
System.getProperties().entrySet().forEach(e -> {
System.out.println(e.getKey() + " : " + e.getValue());
});

TA贡献1828条经验 获得超3个赞
您可以使用 FileHandler
"%t" 系统临时目录 "%h" "user.home" 系统属性的值
https://kodejava.org/how-do-i-get-operating-system-temporary-directory-folder/
public class TempDirExample {
public static void main(String[] args) {
// This is the property name for accessing OS temporary directory
// or folder.
String property = "java.io.tmpdir";
// Get the temporary directory and print it.
String tempDir = System.getProperty(property);
System.out.println("OS temporary directory is " + tempDir);
}
}
或者您可以通过属性文件传入目录。
添加回答
举报