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);
}
}
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短