This discussion is archived
1 2 Previous Next 18 Replies Latest reply: Dec 26, 2007 8:46 AM by 807603 RSS

File fp = new File(filePath);fp.exists() does not yeild proper result

807603 Newbie
Currently Being Moderated
Below given is the code to check if a file exists.

I am using "jdk1.5.0_13"

This code works on Windows but on Linux it fails even when the file exists.
Please let me know if you have a solution or a work around for this.

Also ,it is not a slash versus backslash issue.
I gave the path as /tmp/file.txt on Linux and c:\file.txt on windows.
On windows i get the correct answer but on linux the
API returns false even when the file exists.

boolean DoesTheFileExist(String filePath)
{
File fp = new File(filePath);
if(true == fp.exists())
{
return true;
}
else
{
return false;
}
}

Regards,
Ganesh
1 2 Previous Next