import java.io.File;
/**
* 运用递归 取某个目录下的所有子目录及文件
* @author kehuailin
*
*/
public class DirDiGui
{
public static void main(String[] args) throws Exception
{
String s = " c:/test " ;
getDir(s);
}
static void getDir(String strPath) throws Exception
{
try
{
File f = new File(strPath);
if (f.isDirectory())
{
File[] fList = f.listFiles();
for ( int j = 0 ; j < fList.length; j ++ )
{
if (fList[j].isDirectory())
{
System.out.println(fList[j].getPath());
getDir(fList[j].getPath());
}
else
{
System.out.println(fList[j].getPath());
}
}
}
}
catch (Exception e)
{
System.out.println( " Error: " + e);
}
}
}