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 婆婆66岁祝福语简短
13 今天孩子高考祝福语简短
14 送彩票生日祝福语简短
15 分别祝福语简短情话英文
16 画室揭牌仪式祝福语简短
17 女友妈妈生日祝福语简短
18 离别赠言离职祝福语简短