Java Programming
Find out the directory
tomato13
2009. 7. 3. 14:26
public class FindDirectories {
public static void main(String[] args) {
try {
File pathName = new File("c:\\");
String[] fileNames = pathName.list();
for (int i = 0; i < fileNames.length; i++) {
File tf = new File(pathName.getPath(), fileNames[i]);
if(tf.isFile()) {
System.out.println("File: " + tf.getCanonicalPath());
}
else if (tf.isDirectory()) {
System.out.println("Dir: " + tf.getCanonicalPath());
}
}
} catch (IOException e) {
System.out.println("Error: " + e);
}
}
}