Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-26-2007, 04:25 PM
Member
 
Join Date: Dec 2007
Posts: 1
ganeshp is on a distinguished road
File fp = new File(filePath);fp.exists() does not yeild proper result
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);
return fp.exists();
}

Regards,
Ganesh

Last edited by ganeshp : 12-26-2007 at 04:43 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-27-2007, 12:42 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 839
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
Your segment of code appears correct. Do you have the correct permissions on Linux to decipher whether you have the file or not? Please post your currently functioning code because having others run and test your code will bring your question to a swifter resolution. And remember to use code tags.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check whether file is exists or not Java Tip java.io 0 04-05-2008 11:13 AM
How to read a text file from a Java Archive File Java Tip Java Tips 0 02-08-2008 10:13 AM
Simply output the result to a text file. silvia New To Java 1 08-07-2007 06:48 AM
Regarding conversion of Image file to Video file RamaDeviMsc Advanced Java 0 06-25-2007 03:28 PM
count character in text file as input file aNNuur New To Java 0 06-18-2007 07:46 AM


All times are GMT +3. The time now is 05:28 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org