我的當前目錄有文件registers.xml和MySaxparser.java。但是當我使用新的File(「register.xml」)時,我仍然收到File not found錯誤;解決文件路徑 - 在Eclipse中找不到'文件未找到'錯誤
我的CWD是:C:\用戶\ 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");