【发布时间】:2013-09-26 16:35:02
【问题描述】:
我的当前目录有文件 registers.xml 和 MySaxparser.java。但是当我使用 new File("register.xml"); 时,我仍然收到 File not found 错误;
我的密码是:C:\Users\nb\workspaceAndroid\MySaxParser
我使用的是 Java 1.7,windows 上的 Eclipse 平台
public static void main(String[] args) {
File file1 = new File("register.xml");
if(file1.exists()){
System.out.println("File existed");
}else{
System.out.println("File not found!");
}
System.out.println("Working Directory = " + System.getProperty("user.dir"));
输出:
File not found!
Working Directory = C:\Users\nb\workspaceAndroid\MySaxParser
我尝试了下面的行,但也没有用。
File file1 = new File("C:\\Users\\nb\\workspaceAndroid\\MySaxParser\\register.xml");
【问题讨论】:
标签: java eclipse filepath workspace