|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
||||
|
||||
|
Java: Browsing the file system
what i want to do is list the files of a directory...
i realize that the java.io package supports openning files and stuff... but i can't seem to find anything for listing files... |
|
#2
|
||||
|
||||
|
i should probably add that i'm making a command line program... not an applet...
i'm really just looking to make a class to handle something. |
|
#3
|
||||
|
||||
|
hey, for anyone keeping track... i figured it out...
importing the java.io package, use the File class... Code:
path = "C:\whatever";
File dir = new File(path);
String[] list = dir.list();
String output = "";
for (int i = 0; i < list.length; i++) {
output += list[i]+"\n";
}
System.out.println(output);
Mind you, it doesn't distinguish between folder or file... it will simply list anything within the directory... and not recursively... still a useful peice of code that i never knew before! =) (hope someone finds its useful) |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > Java: Browsing the file system |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|