I've had a few tricky problems with files, so I'll just show you, what I do to solve them.
- File myFile = new File("\\path\\to\\file.xml");
-
System.out.println("The file \"" + myFile.getAbsolutePath() + (myFile.exists() ? "\" exists." : "\" doesn't exist."));
Then check the output - is the File path correct? Does that line say, that the file exists? Probably the path is just slightly wrong in some way. (e.g. missing letter or
File.seperator(), extra characters, etc.)
If the file exists, the output would look like this:
The file "\path\to\file.xml" exists.
Does that help?
Greetings,
Nepomuk
PS.: In case you didn't know, the line
- System.out.println("The file \"" + myFile.getAbsolutePath() + (myFile.exists() ? "\" exists." : "\" doesn't exist."));
is short for
- if(myFile.exists())
-
System.out.println("The file \"" + myFile.getAbsolutePath() + "\" exists.");
-
else
-
System.out.println("The file \"" + myFile.getAbsolutePath() + "\" doesn't exist.");