Another Recursion...

I am trying to write a small app that will recursivly add all files and files in sub directories to a ArrayList. The code I am using is more or less a cut and paste taken from this post:

http://forum.java.sun.com/thread.jspa?threadID=674245&messageID=3938703

I declare all my variables publicly. Not sure if that was the best idea, but it allows me to access them easily from non static methods. This also isn't the complete code. The app accepts arguments from the command line, and checks them for validity (ex. is the user entered starting directory a directory)

publicclass AllFiles{

public File fnfArray[]=null, currentFile=null, source;//Files and Folders array

public List fnfList;//Files and Folders List

public ArrayList list, deeperList;

public Iterator filesIter;

publicstaticvoid main (String args[]){

AllFiles all=new AllFiles();

all.source=args[0]//this isn't how i do it, pretend it sets source to a directory.

all.getFiles(all.source);

public ArrayList getFiles(File startDir)

{

list=new ArrayList();

fnfArray=startDir.listFiles();

fnfList=Arrays.asList(fnfArray);

filesIter=fnfList.iterator();

while(filesIter.hasNext()){

currentFile=(File)filesIter.next();

currentFile=currentFile.getAbsoluteFile()

list.add(currentFile);

if(currentFile.isDirectory()){

deeperList=getFiles(currentFile);

list.addAll(deeperList);

}

}

Collections.sort(list);

return list;

}

}

The two reason I am writing is:

1) this compiles but erros.

2) here is the error:

Exception in thread "main" java.lang.NullPointerException

at java.util.Arrays$ArrayList.<init>(Arrays.java:2342)

at java.util.Arrays.asList(Arrays.java:2328)

at hogan.getFiles(hogan.java:34)

at hogan.getFiles(hogan.java:41)

at hogan.main(hogan.java:26)

I read something about Arrays.java.2342/2328 being a bug in Java, but it always seemed to be related to web development. Any ideas. Thanks a ton, I am extremly new to programming, and it was this forum that got me this far.

HippieJoe

[3046 byte] By [HippieJoea] at [2007-10-2 14:18:27]
# 1
I see I left a closing bracket of my Main method...just a typo, it's there in the program. Any advice as to what that error is? Does anyone have just a simple recursive method to load all files found into a array? Thanks again!HippieJoe
HippieJoea at 2007-7-13 12:35:32 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...