List of usage examples for java.io File listFiles
public File[] listFiles()
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 w w .j a v a2s .c om } } }
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();/* w w w . j ava 2s.c o m*/ } } }
From source file:net.sf.sripathi.ws.mock.util.FileUtil.java
private static void deleteFiles(File file) { if (file.listFiles() != null) { for (File child : file.listFiles()) { if (child.isDirectory()) { deleteFiles(child);//from w w w . ja va 2s . c o m child.delete(); } else { child.delete(); } } } }
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();//www .ja v a2s . c o m } } }
From source file:Main.java
/** * return all the files contained in the specified directory *//*from w ww .j a v a 2s. co m*/ public static void fileList(String directoryName, ArrayList<File> files) { File directory = new File(directoryName); // get all the files from a directory File[] fList = directory.listFiles(); for (File file : fList) { if (file.isFile()) { files.add(file); } else if (file.isDirectory()) { fileList(file.getAbsolutePath(), files); } } }
From source file:Main.java
public static boolean checkApkIsExist(String apkSaveName) { boolean isExist = false; File directory = new File(DOWNLOADPATH); if (directory.exists()) { File[] files = directory.listFiles(); for (int i = 0; i < files.length; i++) { String fileName = files[i].getName(); if (fileName.endsWith(".apk")) { fileName = fileName.substring(0, fileName.length() - 4); if (fileName.equals(apkSaveName)) { isExist = true;/* w ww.j a v a 2 s . c o m*/ break; } } } } return isExist; }
From source file:de.netallied.functionblock.converter.java2java.util.Directory.java
/** * //from w w w . j a v a2s . c o m * @param folder * @param recursive * @return ArrayList[File] */ public static ArrayList getAll(File folder, boolean recursive) { ArrayList list = new ArrayList(); File[] files = folder.listFiles(); // directory doesn't exists -> return empty set if (files == null) return list; // String inhalt= FileUtils.readFileToString(file,"ISO-8859-1"); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { if (recursive) { list.addAll(getAll(files[i], recursive)); } } else { list.add(files[i]); } } return list; }
From source file:Main.java
public static void DeleteBookmarkedHtmlResource(File fileOrDirectory) { try {//from ww w. j a v a2s .c o m if (fileOrDirectory.isDirectory()) for (File child : fileOrDirectory.listFiles()) DeleteBookmarkedHtmlResource(child); fileOrDirectory.delete(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static List<File> getFiles(Context context, String ext) { File dir = context.getFilesDir(); final List<File> files = new ArrayList<File>(); File[] subFiles = dir.listFiles(); if (subFiles != null) { for (File file : subFiles) { if (file.isFile() && file.getName().endsWith(ext)) { files.add(file);//from w ww .j a va2 s . c o m } } } return files; }
From source file:Main.java
private static void deleteContent(File dir, boolean deleteDir) { if (dir.isDirectory()) { File[] files = dir.listFiles(); for (File file : files) { deleteContent(file, true);//from ww w.ja va 2 s. c o m } } if (deleteDir) dir.delete(); }