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 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短