import java.io.*;
import java.util.*;
class FindJavaFilesDemo
{
public static void main(String[] args) throws IOException
{
List<File> listFiles = new ArrayList<File>();
find(new File("d:\\works\\"),listFiles);
BufferedWriter bw = new BufferedWriter(new FileWriter(new File("d:\\works\\list.txt")));
Collections.reverse(listFiles);
for(File f : listFiles)
{
bw.write(f.getAbsolutePath());
bw.newLine();
bw.flush();
}
bw.close();
}
public static void find(File dir,List<File> listFiles)
{
File[] files = dir.listFiles();
for(File file : files)
{
if(file.isDirectory())
{
find(file,listFiles);
}
else
{
if(file.getName().endsWith(".java"))
listFiles.add(file);
}
}
}
}
import java.util.*;
class FindJavaFilesDemo
{
public static void main(String[] args) throws IOException
{
List<File> listFiles = new ArrayList<File>();
find(new File("d:\\works\\"),listFiles);
BufferedWriter bw = new BufferedWriter(new FileWriter(new File("d:\\works\\list.txt")));
Collections.reverse(listFiles);
for(File f : listFiles)
{
bw.write(f.getAbsolutePath());
bw.newLine();
bw.flush();
}
bw.close();
}
public static void find(File dir,List<File> listFiles)
{
File[] files = dir.listFiles();
for(File file : files)
{
if(file.isDirectory())
{
find(file,listFiles);
}
else
{
if(file.getName().endsWith(".java"))
listFiles.add(file);
}
}
}
}