2 回答

TA貢獻(xiàn)1836條經(jīng)驗 獲得超3個贊
我們可以在您的項目中使用許多系統(tǒng)屬性。有些列在官方文檔中。休息一下,你可以得到一個小片段。
System.getProperties().entrySet().forEach(e -> {
System.out.println(e.getKey() + " : " + e.getValue());
});

TA貢獻(xiàn)1828條經(jīng)驗 獲得超3個贊
您可以使用 FileHandler
"%t" 系統(tǒng)臨時目錄 "%h" "user.home" 系統(tǒng)屬性的值
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);
}
}
或者您可以通過屬性文件傳入目錄。
添加回答
舉報