Java如何获取操作系统的临时目录/文件夹?
要获取临时目录的位置,我们可以使用System.getProperty(String)方法并将属性键"java.io.tmpdir"作为参数传递给该方法。
package org.nhooo.example.lang;
public class TempDirExample {
public static void main(String[] args) {
//这是用于访问操作系统临时目录的属性名称
//或文件夹。
String property = "java.io.tmpdir";
//获取临时目录并打印。
String tempDir = System.getProperty(property);
System.out.println("OS temporary directory is " + tempDir);
}
}
热门推荐
10 打牌翻盘祝福语简短
11 国庆求婚祝福语简短精辟
12 祝福语赠言给老师简短
13 师姐毕业送花祝福语简短
14 学院祝福语女生大全简短
15 简短的祝福语12字
16 姐姐生日祝福语漂亮简短
17 老师开工仪式祝福语简短
18 文学短句祝福语大全简短