指定创建临时文件的默认目录
import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; /* 来自 *时代Java - N o w J a v a . c o m*/ public class Main { public static void main(String[] args) { Path basedir = FileSystems.getDefault().getPath("C:/folder1/tmp"); String tmp_file_prefix = "test_"; String tmp_file_sufix = ".txt"; try { Path tmp_3 = Files.createTempFile(basedir, tmp_file_prefix, tmp_file_sufix); System.out.println("TMP: " + tmp_3.to