Example usage for java.io File isDirectory

List of usage examples for java.io File isDirectory

Introduction

In this page you can find the example usage for java.io File isDirectory.

Prototype

public boolean isDirectory() 

Source Link

Document

Tests whether the file denoted by this abstract pathname is a directory.

Usage

From source file:Main.java

public static void deleteDirectory(File dir) {
    if (dir.isDirectory()) {
        File[] listFiles = dir.listFiles();
        for (int i = 0; i < listFiles.length; i++) {
            deleteDirectory(listFiles[i]);
        }/*from   w w  w . j  a  v a 2 s.  co  m*/
    }
    dir.delete();
}

From source file:Main.java

public static boolean isBDMV(File dir) {
    if (dir.isDirectory()) {
        File bdmvDir = new File(dir, "BDMV");
        File certificateDir = new File(dir, "CERTIFICATE");
        if (bdmvDir.exists() && certificateDir.exists()) {
            return true;
        }/*from w  w  w  . j  a  v  a  2 s  .  co  m*/
    }
    return false;
}

From source file:Main.java

public static void deleteFile(File oldPath) {
    if (oldPath.isDirectory()) {
        File[] files = oldPath.listFiles();
        for (File file : files) {
            deleteFile(file);/*from  ww w . jav  a 2  s . c  o  m*/
        }
    }
    oldPath.delete();
}

From source file:Main.java

public static void deleteNonFolders(File paramFile) {
    if (paramFile.isDirectory()) {
        File[] arrayOfFile = paramFile.listFiles();
        int i = arrayOfFile.length;
        for (int j = 0; j < i; j++)
            deleteNonFolders(arrayOfFile[j]);
    }// w  w  w  . j ava  2s  . c o m
}

From source file:Main.java

private static void deleteDirectory(File directory) {
    if (directory.isDirectory()) {
        for (String item : directory.list()) {
            new File(directory, item).delete();
        }//from   w w  w .ja  v a2 s.  c o m
        directory.delete();
    }
}

From source file:Main.java

public static void listFilesInDirectory(File dir) throws Exception {
    String tempfolder = System.getProperty("java.io.tmpdir");
    String pathRequiredForFile = null;
    File[] files = dir.listFiles();
    if (files == null) {
        return;// w  w  w. j  a  va  2s. com
    }
    for (File f : files) {
        if (f.isDirectory()) {
            pathRequiredForFile = f.getName();
            listFilesInDirectory(f);
        } else {
            System.out.println(f.getName());
            File path = new File(tempfolder + "//" + pathRequiredForFile);
            path.mkdir();
            OutputXml(f, path.getAbsolutePath());
        }
    }
}

From source file:Main.java

/**
 * Set starting dir and file for a chooser.
 * chooser.setSelectedFile doesn't work correctly when given a directory.
 *
 * @param chooser/*from   w w  w  .j a va2  s . com*/
 * @param file
 */
public static void setSelectedFile(JFileChooser chooser, File file) {
    if (file.isDirectory())
        chooser.setCurrentDirectory(file);
    else
        chooser.setSelectedFile(file);
}

From source file:Main.java

public static boolean deleteFolder(File dir) {
    if (dir.isDirectory()) {
        String[] children = dir.list();
        for (int i = 0; i < children.length; i++) {
            boolean success = deleteFolder(new File(dir, children[i]));
            if (!success) {
                return false;
            }//from   www  .jav a  2 s .c o m
        }
    }
    return dir.delete();
}

From source file:Main.java

private static void deleteFileOrDirectory(File file) {
    if (file.isDirectory()) {
        File[] subFiles = file.listFiles();
        for (File sf : subFiles) {
            if (sf.isFile())
                sf.delete();/*from w w w  .ja  va  2  s. co  m*/
            else
                deleteFileOrDirectory(sf);
        }
    }
    file.delete();
}

From source file:Main.java

private static void deleteFolder(File fileOrDirectory) {
    if (fileOrDirectory.isDirectory()) {
        for (File child : fileOrDirectory.listFiles())
            deleteFolder(child);//from  w  ww  .  ja v  a  2  s  .co  m
    }
    fileOrDirectory.delete();
}