[ajax-user] (no subject)
Brought to you by:
vamp201
From: <Mor...@cs...> - 2003-04-25 03:25:35
|
I get a NullerPointerException using the code below (java GetFilesByExt C:\\New txt). {Note: New.txt is a file under my C:\ directory}. I thought if I supply (1) a directory to a path and (2) an extension then the class would return all the file-names under that directory having such an extension. Is my interpretation incorect? This is the code I'm executing: import caramel.util.FileUtils; import java.io.File; public class GetFilesByExt { public static void main(String[] args) { if(args.length <2){ System.out.println("Usage: java GetFilesByExt <directory path> <file extension>"); System.exit(-1); } // Get files by extension File[] files = FileUtils.findByExt(new File(args[0]), args[1]); System.out.println("length of files array= " +files.length); //System.out.println("files1= " +files[1]); for(int i = 0;i <files.length;i++) { System.out.println(files[i].getName()); } } } I added the display of the 'files' array and it always comes back 0, which explains why the class returns nothing. Can anyone explain how I'm improperly using this class? Thanks, Danny |