FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


java help





clydejaw
At the moment I'm trying to figure out how to do a search through a folder and list all the files by using System.out.

I am currently using a forloop to trace all the files, but it could only trace one folder. My objective is to go through every folders in one particular folder, it thats not confusing.

E.G.

search directory folder: folder1...

file1
file2
file3...
folder2 <---- how do i make it so it includes folder 2?

Is there any easier way than using a forloop?

cheers.
MrBlueSky
Make a function that loops trough the directory and calls itself recursively when it encounters a folder:

Pseudocode:

Code:


function processFiles(Folder folder) {

  while ((item = nextitem in Folder) != null) {

    if (item is file) {
       // do something with file
    }
    if (item is folder) {
       processFiles(item)
    }

}



Or post the code you have so far so I can be more concrete. But this should help you on your way.
Related topics
JAva HELP
Does anypne help me about JAVA on UNIX?
Java Help
java help:how does dynamic instantiation of classess happen?
java help:
I need a javascript!!! Help!
Help with php and java script
JAVA hElp
Java Help
java help
[Java] Wanna help me figure out this error?
Help needed for making a server in java....
Constructors in Java, help
java help pls!
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.