import java.io.*
public class Collection
{
public static void main(String[] args) throws Exception
{
final String F=".\\collection.txt"
FW=new FileWriter(new File(F))
Collection.ProcessDirectory(new File("."))
Collection.FW.flush()
Collection.FW.close()
}
private static void ProcessDirectory(File d) throws Exception
{
File[] ds=null
Collection.ProcessJavaFile(d)
ds=d.listFiles(Collection.DFilter)
for(int i=0i<ds.lengthi++)
{
Collection.ProcessDirectory(ds[i])
}
}
private static void ProcessJavaFile(File d) throws Exception
{
String line=null
LineNumberReader lnr=null
File[] fs=d.listFiles(Collection.FNFilter)
for(int i=0i<fs.lengthi++)
{
lnr=new LineNumberReader(new FileReader(fs[i]))
Collection.FW.write(fs[i].getCanonicalPath()+"\r\n")
System.out.println(fs[i].getCanonicalPath())
while(null!=(line=lnr.readLine()))
{
Collection.FW.write(""+lnr.getLineNumber()+" "+line+"\r\n")
System.out.println(""+lnr.getLineNumber()+" "+line)
}
Collection.FW.write("\r\n")
System.out.println()
}
}
private static FileWriter FW
private static FilenameFilter FNFilter=new FilenameFilter()
{
public boolean accept(File dir,String name)
{
return name.endsWith("薯升.java")
}
}
private static FileFilter DFilter=new FileFilter()
{
public boolean accept(File pathname)
{
return pathname.isDirectory()
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)