List of usage examples for java.io File isDirectory
public boolean isDirectory()
From source file:Main.java
private static boolean makeDirectory(String path) { if (path == null) { return false; }//w w w. j ava 2 s . c om File directory = new File(path); return directory.exists() && directory.isDirectory() || directory.mkdirs(); }
From source file:Main.java
private static void deleteFilesByDirectory(File directory) { if ((directory != null) && directory.exists() && directory.isDirectory()) { for (File item : directory.listFiles()) { item.delete();/*w ww .j a v a 2 s . c om*/ } } }
From source file:Main.java
private static void innerListFiles(Collection<File> files, File directory, FileFilter filter) { File[] found = directory.listFiles(filter); if (found != null) for (File file : found) if (file.isDirectory()) innerListFiles(files, file, filter); else/*from w ww .j a v a2 s . c om*/ files.add(file); }
From source file:Main.java
public static void deleteFilesByDirectory(File directory) { if (directory != null && directory.exists() && directory.isDirectory()) { for (File item : directory.listFiles()) { item.delete();//from w w w.jav a 2 s .c o m } } }
From source file:Main.java
private static void deleteFilesByDirectory(File directory) { if (directory != null && directory.exists() && directory.isDirectory()) { for (File item : directory.listFiles()) { item.delete();//from ww w . ja va2s .co m } } }
From source file:Main.java
public static File getSaveGameDir() { if (savesDir != null) { return savesDir; }//from w ww.j ava 2 s . c o m File userHome = new File(System.getProperty("user.home")); File userMaps = new File(userHome, "saves"); if (!userMaps.isDirectory() && !userMaps.mkdirs()) { // if it does not exist and i cant make it throw new RuntimeException("can not create dir " + userMaps); } savesDir = userMaps; return userMaps; }
From source file:Main.java
/** Empty this directory. * @return true if the delete was successful. *///from ww w . jav a 2 s.c om public static boolean empty(File file) { if (file.isDirectory() == false) { return false; } boolean success = true; File[] children = file.listFiles(); for (int a = 0; a < children.length; a++) { if (delete(children[a]) == false) success = false; } return success; }
From source file:Main.java
public static boolean isFolderExist(String directoryPath) { if (TextUtils.isEmpty(directoryPath)) { return false; }/*from ww w. j a v a 2 s . c om*/ File dire = new File(directoryPath); return (dire.exists() && dire.isDirectory()); }
From source file:Main.java
public static void deleteDir() { File dir = new File(SD_PATH); if (!dir.exists() || !dir.isDirectory()) return;/*from ww w . j a va 2 s .c om*/ for (File file : dir.listFiles()) { if (file.isFile()) file.delete(); else if (file.isDirectory()) deleteDir(); } dir.delete(); }
From source file:Main.java
public static void deleteFile(File file) { if (file.exists()) { if (file.isDirectory()) { File[] files = file.listFiles(); for (File file2 : files) { if (file2.isDirectory()) { deleteFile(file2);/*from ww w . ja va2 s . c o m*/ } else { file2.deleteOnExit(); } } } file.deleteOnExit(); } }