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);
}
}
}
'Java Programming' 카테고리의 다른 글
current thread name (0) | 2009.07.12 |
---|---|
jar file의 manifest 내역 수정 (0) | 2009.07.03 |
display long value with ',' seperator (0) | 2009.06.29 |
loop 안과 밖에서의 obj.class.getName() 사용 performance 비교 (0) | 2009.06.14 |
loop 안과 밖의 try/catch에 따른 performance (0) | 2009.06.08 |