Java文件。exists()找不到XML文件
我只是想找出XML文件是否存在。我有以下代码:
File f = new File("customers/jim.xml");
File g = new File("customers/jim.txt");
if(f.exists())
{
System.out.println("File f exists!");
}
else
{
System.out.println("File f not found!");
}
if(g.exists())
{
System.out.println("File g exists!");
}
else
{
System.out.println("File g not found!");
}
输出:
File f not found!
File g exists!
找到了文本文件,但找不到xml文件。两个文件都在同一个文件夹中,拼写确实正确。有人知道我做错了什么吗
# 1 楼答案
一切看起来都是正确的,所以有几件事需要检查: