Results 1 to 3 of 3
  1. #1
    ganeshp is offline Member
    Join Date
    Dec 2007
    Posts
    1
    Rep Power
    0

    Default 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 03:43 PM.

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    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.

  3. #3
    derekitishere is offline Member
    Join Date
    Apr 2009
    Posts
    3
    Rep Power
    0

    Default I want to say hi

    My name is Derek and
    I'm glad to join to this forum.

Similar Threads

  1. count character in text file as input file
    By aNNuur in forum New To Java
    Replies: 7
    Last Post: 03-25-2010, 04:01 PM
  2. How to check whether file is exists or not
    By Java Tip in forum java.io
    Replies: 0
    Last Post: 04-05-2008, 10:13 AM
  3. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:13 AM
  4. Simply output the result to a text file.
    By silvia in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:48 AM
  5. Regarding conversion of Image file to Video file
    By RamaDeviMsc in forum Advanced Java
    Replies: 0
    Last Post: 06-25-2007, 02:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •