package newcode;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.File;
public class File {
public static void main(String [] args){
File file =new File("FileName.txt");
上面这行显示错误“构造函数文件(字符串)未定义”
try{
if(!file.exists()){
上面的这一行显示了一个错误“该方法存在()未定义为类型文件”
file.createNewFile();
}
上面这行显示了一个错误“方法 createNewFile() 未定义为类型文件”
PrintWriter pw= PrintWriter(file);
上一行之后的错误“未定义文件类型的 PrintWriter(File) 方法”
pw.println("File text started here:");
}
catch(IOException e){// here error shows
e.printStackTrace();
}
}
}
重命名您的班级。当您实例化 File 类时,它认为您引用的是您自己的类。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句