为什么我会收到错误“文件无法解析为某种类型”?
这是我的代码的一部分
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 Constracture是可修改的,但我仍然收到此错误: File cannot be resolved to a type
问题是什么?
你错过了很多机会:
import java.io.File;
从源文件的顶部。
你可以用
import java.io.*;
我通常使用单一类型的导入。
你需要包括
import java.io.File;
要么
import java.io.*;
在源文件的顶部。
您很可能忘记导入java.io.File但基本上编译器告诉您它无法找到“File”类。
有关详细信息,请参阅此特定于“ 文件无法恢复为某种类型 ”的java错误页面。
我曾经收到过这个错误,即使我已经导入了java.io.File。 我认为这是一些奇怪的,临时的Eclsipse故障。 当我对代码进行其他更改,然后再次保存时,错误自行解决。
- 如何关闭电源,从应用程序重启对话框?
- 解析json的问题
- 我正在使用eclipse,我得到了这个错误 – 我认为这是我导入becker.robots的方式的错误
- AsyncTasks不会被收集,导致其他AsyncTasks无法运行
- Java String to Date Conversion抛出Unparseable日期
- java中的回车符(“\ r \ n”)
- Google Drive SDK API未列出Google Drive在Google中上传的文件
- Firestore – 在本地合并两个查询
- Android Tab Fragment(Eclipse ApI 22)中不推荐使用ActionBarActivity和ActionBar.TabListener