1public class Pathnames {
2
3 public static void main(String[] args) {
4 // Creates an array in which we will store the names of files and directories
5 String[] pathnames;
6
7 // Creates a new File instance by converting the given pathname string
8 // into an abstract pathname
9 File f = new File("D:/Programming");
10
11 // Populates the array with names of files and directories
12 pathnames = f.list();
13
14 // For each pathname in the pathnames array
15 for (String pathname : pathnames) {
16 // Print the names of files and directories
17 System.out.println(pathname);
18 }
19 }
20}
21