Results 1 to 5 of 5
  1. #1
    augustas656 is offline Senior Member
    Join Date
    Apr 2014
    Location
    United Kingdom
    Posts
    193
    Rep Power
    6

    Default Get list, map or array of a specific file type files in a directory?

    If I specify the directory in file type or path string type how can I get a list of files that are file type .yml in that folder, so I can loop through and do something with each single file.yml in that specified directory.

    Regards
    augustas656

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Get list, map or array of a specific file type files in a directory?

    Check out the File class and FilenameFilter interface in the JDK API.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    450
    Rep Power
    11

    Default Re: Get list, map or array of a specific file type files in a directory?

    Create a Flie object using the directory where you have put your files and use list() of File class to get all the list of files and the just check the file extension with the help of if statement.

    Now inside the if statement, you can get the files whichever with desire extension.

    Thanks
    Pandian
    Mak
    (Living @ Virtual World)

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Get list, map or array of a specific file type files in a directory?

    Quote Originally Posted by makpandian View Post
    get all the list of files and the just check the file extension with the help of if statement.
    Didn't you see jim89's response above yours? Why are you posting bad advice?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    450
    Rep Power
    11

    Default Re: Get list, map or array of a specific file type files in a directory?

    @DB

    Oh, I did not see that. :-(
    Mak
    (Living @ Virtual World)

Similar Threads

  1. Get directory files list as a stream
    By Dijkstra in forum Advanced Java
    Replies: 4
    Last Post: 05-04-2012, 12:26 PM
  2. Create a table with buttons and the files list of a directory.
    By danielpereira in forum Advanced Java
    Replies: 1
    Last Post: 11-22-2010, 06:43 PM
  3. Populating a gui list box with the files in a directory
    By josejvelezcolon in forum New To Java
    Replies: 1
    Last Post: 08-10-2009, 04:50 PM
  4. how to list certain files in a given directory in java
    By corpusluteum in forum New To Java
    Replies: 6
    Last Post: 09-24-2008, 12:19 AM
  5. 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

Posting Permissions

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