Results 1 to 5 of 5

Thread: List directory

  1. #1
    dman is offline Member
    Join Date
    Aug 2009
    Posts
    5
    Rep Power
    0

    Question List directory

    Hi

    I'm kinda new to java and i was wondering how can i list a local or a remote directory on a JList or something like that.

    Thank you for your time.:)

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    5

    Default

    Java Code:
    File file = new File("c:/"); //or where ever you like
    
    File[] files = file.listFiles();
    for(File f : files)
    {
       System.out.println(f);
    }

  3. #3
    dman is offline Member
    Join Date
    Aug 2009
    Posts
    5
    Rep Power
    0

    Default

    do you know how can i list the directory on a jList ? :confused:

    Thanks!

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Once you have the array, the rest of the problem is to put it into a JList. This tutorial will help with this: How to Use Lists

    If you go through the tutorial and still have problems, then you'd be best served to post your code (with code tags) and we can help figure out any areas of misunderstanding.

    Much luck.

  5. #5
    dman is offline Member
    Join Date
    Aug 2009
    Posts
    5
    Rep Power
    0

Similar Threads

  1. 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
  2. Linked List integer list
    By igniteflow in forum Advanced Java
    Replies: 1
    Last Post: 12-10-2008, 08:53 PM
  3. How to access ArrayList in List of List?
    By alvations in forum New To Java
    Replies: 5
    Last Post: 10-08-2008, 12:23 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

Tags for this Thread

Posting Permissions

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