The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
August 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Use File 'n FileFilter

Posted by Anil S. Karkera on August 05, 2001 at 1:25 AM

'ere is something for you to start with...

===

import java.io.*;

public class DirStructure{

public void showDirStructure(File searchFile){
File[] directoryStore;
directoryStore = searchFile.listFiles(new ApplyDirFilter());
for(int i=0; i System.out.println(directoryStore[i].getAbsolutePath());
showDirStructure(directoryStore[i]);
}
}

class ApplyDirFilter implements FileFilter{
public boolean accept(File f) {
return f.isDirectory();
}
}

public static void main(String[] args){
File f = new File("c:/");
new DirStructure().showDirStructure(f);
}
}

-ak-



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us