List of usage examples for java.io File isDirectory
public boolean isDirectory()
From source file:Main.java
/** * IF THE DIRECTORY IS NOT EMPTY . USE THIS FUNCTION *//* www .ja va 2s.co m*/ public static boolean deleteNon_EmptyDir(File dir) { if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { boolean success = deleteNon_EmptyDir(new File(dir, children[i])); if (!success) { return false; } } } return dir.delete(); }
From source file:Main.java
public static void deleteFileInDirectory(File file) { if (file.isDirectory()) { File[] files = file.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isFile()) { files[i].delete();//from w w w . j a v a 2 s. c o m } else { deleteFileInDirectory(files[i]); } } } else { file.delete(); } }
From source file:Main.java
public static boolean deleteRecursive(File fileOrDirectory) { if (fileOrDirectory.isDirectory()) { for (File child : fileOrDirectory.listFiles()) { deleteRecursive(child);/*from www . j av a 2s . c o m*/ } } return fileOrDirectory.delete() || !fileOrDirectory.exists(); }
From source file:Main.java
public static void deletes(File specUnZipDir) { if (specUnZipDir.isDirectory()) { File[] listFiles = specUnZipDir.listFiles(); for (File f : listFiles) { deletes(f);/*from w w w . ja v a 2 s . c o m*/ } } else { specUnZipDir.delete(); } }
From source file:Main.java
public static void deleteRecursive(File fileOrDirectory) { if (fileOrDirectory.isDirectory()) { for (File child : fileOrDirectory.listFiles()) { deleteRecursive(child);/*from w w w . ja v a 2 s . c o m*/ } } fileOrDirectory.delete(); }
From source file:Main.java
private static void removeDirectory(File directory) { if (directory.isDirectory()) { File[] files = directory.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { removeDirectory(files[i]); }// w w w . j a v a 2 s . c om files[i].delete(); } directory.delete(); } }
From source file:FolderZiper.java
static private void addFileToZip(String path, String srcFile, ZipOutputStream zip) throws Exception { File folder = new File(srcFile); if (folder.isDirectory()) { addFolderToZip(path, srcFile, zip); } else {// w w w . ja v a 2 s .c o m byte[] buf = new byte[1024]; int len; FileInputStream in = new FileInputStream(srcFile); zip.putNextEntry(new ZipEntry(path + "/" + folder.getName())); while ((len = in.read(buf)) > 0) { zip.write(buf, 0, len); } } }
From source file:Main.java
private static File findPomRoot(File file) { if (file.isDirectory() && new File(file, "pom.xml").exists()) { return file; }//from www. j a va2 s . co m if (file.getParentFile() != null) { return findPomRoot(file.getParentFile()); } return null; }
From source file:Main.java
public static void deleteDirectory(File f) { if (f.isDirectory()) { for (File c : f.listFiles()) deleteDirectory(c);/*from ww w .j av a2 s . c om*/ } f.delete(); }
From source file:Main.java
static public File[] getDirectories(File file) { return file.listFiles(new FileFilter() { @Override// w ww . ja v a2 s .c om public boolean accept(File pathname) { return pathname.isDirectory(); } }); }