Results 1 to 2 of 2
  1. #1
    cecily is offline Member
    Join Date
    Jul 2007
    Posts
    33
    Rep Power
    0

    Default how to find files in given directory

    in my program I have to get directory name&address, in this directory is none, one, or more *.txt(maybe not *.txt files) and I have to read info from all of them.

    on C++ is very easy to do that with "findnext, find last, findfirst", so how can I do this in Java?

  2. #2
    paty is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

    Default

    You can use java.io.File class and its list() or listFiles() method with FilenameFilter argument. Both return a array of filtered file name or File object in a directory.

Similar Threads

  1. Text and image files within jar files
    By erhart in forum Advanced Java
    Replies: 8
    Last Post: 01-19-2008, 04:43 AM
  2. Deleting an directory/subdirectory/files
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-13-2008, 07:18 AM
  3. How can I get list of files in a directory
    By karma in forum New To Java
    Replies: 2
    Last Post: 12-14-2007, 11:20 PM
  4. how to convert mpeg files to .wav files
    By christina in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 04:14 AM
  5. How can i get current directory?
    By Ashley in forum New To Java
    Replies: 1
    Last Post: 05-26-2007, 01:21 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
  •