@@ -0,0 +1,1376 @@
+package ciir.jfoley.chai.io;%0A%0Aimport java.io.File;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.IOException;%0Aimport java.util.*;%0A%0A/**%0A * @author jfoley.%0A */%0Apublic class FS %7B%0A%09// Module.%0A%09private FS() %7B  %7D%0A%0A%09public static List%3CFile%3E listDirectory(String path) throws IOException %7B%0A%09%09return listDirectory(new File(path));%0A%09%7D%0A%0A%09public static List%3CFile%3E listDirectory(File dir) throws IOException %7B%0A%09%09if(!dir.exists()) %7B%0A%09%09%09throw new FileNotFoundException(%22No directory to list! %22+dir);%0A%09%09%7D%0A%09%09if(!dir.canRead()) %7B%0A%09%09%09throw new IOException(%22Can't read directory! Permissions? %22+dir);%0A%09%09%7D%0A%09%09if(!dir.isDirectory()) %7B%0A%09%09%09throw new IOException(%22Isn't a directory: %22+dir);%0A%09%09%7D%0A%0A%09%09File%5B%5D data = dir.listFiles();%0A%09%09if(data == null) %7B%0A%09%09%09throw new IOException(%22Couldn't list the directory -- got all nulls! %22+dir);%0A%09%09%7D%0A%0A%09%09return Arrays.asList(data);%0A%09%7D%0A%0A%09public static List%3CFile%3E findFilesRecursively(File base) throws IOException %7B%0A%09%09List%3CFile%3E foundFiles = new ArrayList%3C%3E();%0A%09%09Queue%3CFile%3E directories = new LinkedList%3C%3E();%0A%09%09directories.add(base);%0A%0A%09%09while(!directories.isEmpty()) %7B%0A%09%09%09System.out.println(directories);%0A%09%09%09File possible = directories.poll();%0A%09%09%09assert(possible != null);%0A%09%09%09for (File file : listDirectory(possible)) %7B%0A%09%09%09%09if(file.isDirectory()) %7B%0A%09%09%09%09%09directories.offer(file);%0A%09%09%09%09%7D else %7B%0A%09%09%09%09%09foundFiles.add(file);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return foundFiles;%0A%09%7D%0A%0A%0A%7D%0A

Add FS file