【发布时间】:2013-03-22 06:38:53
【问题描述】:
我正在尝试使用 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);
}
}}
【问题讨论】:
-
Files来自哪个包?我猜应该是File。 -
升级到SE7后报错Desktop\Jdbc\number.java:7: error: cannot find symbol Path tempFile = Files.createTempFile(temp, ".txt"); ^ 符号:变量临时位置:类号 1 错误
标签: java