import javax.swing.*;
import java.io.*;
import java.util.zip.*;

public class Gather {
    BufferedWriter out;

    public static void main(String[] args){
        Gather g = new Gather();
    }

    public Gather() {
        File root;
        JFileChooser chooser = new JFileChooser();

        //get the directory from which the user wants to delete .class files
        chooser.setFileSelectionMode(chooser.DIRECTORIES_ONLY);
        chooser.setDialogTitle("Select a directory to process");
        if (chooser.showOpenDialog(null)==JFileChooser.APPROVE_OPTION){
            try{
                //get the directory
                root = chooser.getSelectedFile();

                //Confirm the deletion
                int rtn = JOptionPane.showConfirmDialog(null,
                    "Are you sure you want to process files in \n" +
                    root.getAbsolutePath(), "Confirm",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE);

                if (rtn == JOptionPane.NO_OPTION ){
                    System.exit(0);
                }

                out = new BufferedWriter(new FileWriter(root.getAbsolutePath()+"FileList.txt"));
                //Blast away!
                processFile( root );
                out.flush();
                out.close();
            }catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.exit(1);
    }

    private void processFile( File root ) throws IOException{
        //get a list of all the files in this directory
        File[] files = root.listFiles();

        //iterate through the files
        for (int i=0; i<files.length;i++){
            //recursively call this method if the file is a directory
            if (files[i].isDirectory()){
                processFile( files[i] );
            } else {
                out.write( files[i].getAbsolutePath());
                out.newLine();
            }
        }
    }
}
1