rmdir - Java File Path IO

Java examples for File Path IO:Directory Create

Description

rmdir

Demo Code


import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.apache.log4j.Logger;

public class Main{
    private static final Logger logger = Logger.getLogger(FileHelper.class);
    /**/*from   w w w . ja v a  2s .co m*/
     * @param foldername
     */
    public static void rmdir(String pathname) {

        logger.debug("..");

        File f = new File(pathname);

        for (String filename : f.list()) {

            String path = new StringBuffer(pathname + File.separator
                    + filename).toString();

            File file = new File(path);

            if (file.isDirectory()) {
                rmdir(path);
            } else {
                file.delete();
            }

        }

        f.delete();

    }
}

Related Tutorials