java如何遍历一个目录,读出其中所有的文件名
|
import java.io.*;
public class Decode
{
static String is_jadpath;
public static void main(String[] args)
{
try{
if (args.length>1)
{
is_jadpath=args[0];
File f=new File(args[1]);
if (f.isDirectory())
{
File newdic=new File(args[1]+"_src");
newdic.mkdir();
recursionFileList(newdic.getPath(),f);
}
else
{
Runtime r=Runtime.getRuntime();
String dimpath=args[1].substring(0,args[1].lastIndexOf('\'));
String cmd=is_jadpath+" -d "+dimpath+" -s java "+args[1];
r.exec(cmd);
}
}
else
{
System.out.println("please input argument");
System.out.println("example d:\jadhome\jad c:\yourdic\yourclass.class");
}
}catch(Exception e)
{System.out.println("wrong:"+e);}
}
private static boolean recursionFileList(String dimparentpath,File f)
throws Exception
{
boolean hasClassFile=false;
File flist[]=f.listFiles();
for(int i=0;i