Skip to main content
gamedev.net
🔒 Locked

[java] Scanning directories

Started by Mulligan May 6, 2003 at 6:59 AM 1 replies 250+ views
Original Post
Mulligan
Mulligan
My program is in one directory and I need to find a way of obtaining an array of strings of all the file names of the files in the directory.
NuffSaid
NuffSaid

  

File currDir = new File(".");
String[] fileList = currDir.list(new FilenameFilter() {
public boolean accept(File dir, String name) {
//list all the files

return true;
}
});

for(int i = 0; i < fileList.length; i++) {
System.out.println("File " + i + ": " + fileList[i]);
}


Hope that helps.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
Mulligan
Mulligan
Well then, thanks.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.