Re: Search files on local disk with java

Discussion in 'Java' started by Marco Schmidt, Jul 30, 2003.

  1. Cy Fy:

    >from a java application, am trying to find if a particular file is already
    >present on the local disk. I just know the file name and do not know the
    >path. I would like to know how a 'search' for a local file could be done
    >from java.
    >I would eventually need the full path so that I could open the file.


    At <http://de.geocities.com/uweplonus/faq/io.html#rekursivVerzeichnis>
    there is some code to scan a directory tree.

    Instead of printing the file name

    // entry ist eine Datei
    System.out.println(entry);

    you could compare it to the name you are looking for, e.g.

    if ("myfile.dat".equals(entry.getName())) {
    System.out.println("File is in directory " + dir.getAbsolutePath());
    }

    Regards,
    Marco
    --
    Please reply in the newsgroup, not by email!
    Java programming tips: http://jiu.sourceforge.net/javatips.html
    Other Java pages: http://www.geocities.com/marcoschmidt.geo/java.html
     
    Marco Schmidt, Jul 30, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jas Shultz
    Replies:
    0
    Views:
    950
    Jas Shultz
    Dec 3, 2003
  2. Andy Fish
    Replies:
    0
    Views:
    809
    Andy Fish
    Jul 30, 2003
  3. Replies:
    12
    Views:
    522
    santosh
    Nov 15, 2006
  4. Alexander Cohen

    copying local files to remote disk

    Alexander Cohen, Oct 15, 2009, in forum: Ruby
    Replies:
    0
    Views:
    101
    Alexander Cohen
    Oct 15, 2009
  5. manish
    Replies:
    5
    Views:
    167
    Bart Van der Donck
    Nov 8, 2008
Loading...

Share This Page