1import java.io.File;
2
3public class Main {
4 public static void main(String[] argv) throws Exception {
5 File dir = new File("directoryName");
6 String[] children = dir.list();
7
8 if (children == null) {
9 System.out.println("does not exist or
10 is not a directory");
11 } else {
12 for (int i = 0; i < children.length; i++) {
13 String filename = children[i];
14 System.out.println(filename);
15 }
16 }
17 }
18}