Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: File class theoretical question

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question File class theoretical question

    I've been learning java for few days, and I've created a simple code using File class, which returns array of files in specified directory. So I have a question: is there any easy way to return array of ALL files in whole directory, here's an example:
    in path c:/ProgramFiles/ there are:
    1) dir1 (which has)
    ..1) dir1.1
    ..2) dir2.2
    ....1)dir2.2.1
    2) dir2
    3) dir3
    and so on.
    So is there any solution how to return all the files/directories (including subfiles and subdirectories)? I would appreciate any hints


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,332
    Thanks
    181
    Thanked 829 Times in 772 Posts
    Blog Entries
    5

    Default Re: File class theoretical question

    Recursively traverse through the directory...in pseudocode:
    1. for each file:
        if directory:
            list files -> go to 1.
        else:
             add to list

Similar Threads

  1. class interfacing to new server question
    By akhalsa in forum Object Oriented Programming
    Replies: 1
    Last Post: February 2nd, 2011, 11:03 PM
  2. Replies: 5
    Last Post: November 13th, 2010, 12:53 PM
  3. Question concerning nextLine() method in Scanner Class
    By r_sardinas in forum Java SE APIs
    Replies: 2
    Last Post: October 20th, 2010, 08:35 PM
  4. .class to .exe question
    By james137 in forum Java Theory & Questions
    Replies: 1
    Last Post: November 3rd, 2009, 08:18 PM
  5. How to link two classes in java to use it method
    By Sterzerkmode in forum Object Oriented Programming
    Replies: 3
    Last Post: May 13th, 2009, 06:52 AM