这是我的部分代码
try{
BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
while ((line= in.readLine())!="exit"){
System.out.println("Enter command");
line=in.readLine();
Command currentCommand=new Command(line);
File currentFile= new File(currentCommand.getLsPath());
currentCommand.getLsPath()
方法返回一个字符串,这是文件构造所必需的,但我仍然得到这个错误:File cannot be resolved to a type
问题是什么?
最佳答案
您可能刚刚错过了:
import java.io.File;
从源文件的顶部开始。
你可以使用
import java.io.*;
我通常使用单一类型的导入。
关于java - 为什么我会收到错误 "File cannot be resolved to a type"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5996989/