public class FindDirectories
{
public static void main(String[] args)
{
// if no arguments provided, start at the parent directory
FindDirectories.FindFiles(new String[]{"c:\\"});
}
public static void FindFiles(String[]str)
{
if (str.length ==0) str = new String[]{".."};
try
{
File pathName = new File(str[0]);
if (pathName.exists() )
{
String[] fileNames = pathName.list();
// enumerate all files in the directory
for (int i = 0; i < fileNames.length; i++)
{
File f = new File(pathName.getPath(), fileNames[i]);
// if the file is again a directory, call the main method recursively
if (f.isDirectory())
{
// System.out.println(f.getCanonicalPath());
FindFiles(new String[]{f.getCanonicalPath()});
}
else
{
System.out.println(f.getCanonicalPath());
}
}
}
}
catch(IOException e)
{