FileDocCategorySizeDatePackage
TmpCleaner.javaAPI DocGlassfish v2 API4109Fri May 04 22:33:24 BST 2007com.sun.enterprise.tools.verifier

TmpCleaner

public class TmpCleaner extends Object
Reads the list of file names from the file cleandirs.txt and calls deleteFile to recursively delete the directories. NOTE : This independent class gets called only on W2K, where the Normal cleanAll() call from doit() in verifier fails.

Fields Summary
private static final String
TMPDIR
Constructors Summary
Methods Summary
private voiddeleteFile(java.io.File p_file)

        String FILE_SEPARATOR = System.getProperty("file.separator");
        // If it is a directory, empty it first
        if (p_file.isDirectory()) {
            String[] dirList = p_file.list();
            for (int i = 0; i < dirList.length; i++) {

                File aFile = new File(
                        p_file.getPath() + FILE_SEPARATOR + dirList[i]);
                if (aFile.isDirectory()) {
                    deleteFile(aFile);
                }
                aFile.delete();
            }
        }
        p_file.delete();
    
public static voidmain(java.lang.String[] args)

        try {
            TmpCleaner t = new TmpCleaner();
            System.gc();
            t.run();
        } catch (Exception e) {
        }
        System.exit(0);
    
public voidrun()


       

        // read the file
        try {
            String cleandirs = TMPDIR + File.separator + "cleandirs.txt"; // NOI18N
            File tmpfile = new File(cleandirs);
            if (!tmpfile.exists())
                return;
            BufferedReader br = new BufferedReader(new FileReader(cleandirs));

            try {
                do {
                    String str = br.readLine();
                    String file = TMPDIR + File.separator + str;
                    File toDelete = new File(file);
                    deleteFile(toDelete);
                    toDelete.deleteOnExit();
                } while (br.ready());
            } catch (Exception e) {
            }


            br.close();
            File f = new File(cleandirs);
            f.delete();
        } catch (Exception e) {
        }