我正在尝试使用 java 创建一个临时文件。但是当我运行我的代码时,它显示以下错误。
number.java:7: cannot find symbol
symbol : class Path
location: class number
Path tempFile = Files.createTempFile(null, ".txt");
^
number.java:7: cannot find symbol
symbol : method createTempFile(<nulltype>,java.lang.String)
location: class Files
Path tempFile = Files.createTempFile(null, ".txt");
^
2 errors
这是代码,当我导入 java.io.file;.then 显示错误包不存在
import java.io.*;
public class number{
public static void main(String args[])
{try {
Path tempFile = Files.createTempFile(null, ".txt");
System.out.format("The temporary file" +
" has been created: %s%n", tempFile);
} catch (IOException x) {
System.err.format("IOException: %s%n", x);
}
}}