List of usage examples for java.io File listFiles
public File[] listFiles()
From source file:Main.java
private static void deleteRecursive(File file) { if (file != null) { File[] children = file.listFiles(); if (children != null && children.length > 0) { for (File child : children) { deleteRecursive(child);/*ww w . j a v a 2s. c om*/ } } else { file.delete(); } } }
From source file:Main.java
public static void deleteDirectory(File directory) { if (directory.exists()) { File[] files = directory.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { deleteDirectory(file); } else { file.delete();// w w w . j a v a 2s . c o m } } } } directory.delete(); }
From source file:Main.java
public static void deleteRecursive(File fileOrDirectory) { if (fileOrDirectory.isDirectory()) for (File child : fileOrDirectory.listFiles()) deleteRecursive(child);/* w ww .ja v a 2 s.c o m*/ fileOrDirectory.delete(); }
From source file:Main.java
public static void deleteRecursive(File fileOrDirectory) { if (fileOrDirectory.isDirectory()) for (File child : fileOrDirectory.listFiles()) { deleteRecursive(child);//from w ww . j a va2 s .c om } fileOrDirectory.delete(); }
From source file:Main.java
public static void copyFiles(String sourcePath, String targetPath) throws IOException { File srcDir = new File(sourcePath); File[] files = srcDir.listFiles(); FileChannel in = null;/*from w ww . j a v a2s.c om*/ FileChannel out = null; for (File file : files) { try { in = new FileInputStream(file).getChannel(); File outDir = new File(targetPath); if (!outDir.exists()) { outDir.mkdirs(); } File outFile = new File(targetPath + File.separator + file.getName()); out = new FileOutputStream(outFile).getChannel(); in.transferTo(0, in.size(), out); } finally { if (in != null) in.close(); if (out != null) out.close(); } } }
From source file:com.runwaysdk.dataaccess.io.instance.InstanceImporterUnzipper.java
private static void importXmlFiles(final File outputDir) { for (File xml : outputDir.listFiles()) { if (xml.getName().endsWith(".xml")) { logger.info("Importing " + xml.getAbsolutePath() + "."); SAXImporter.runImport(xml, "classpath:com/runwaysdk/resources/xsd/datatype.xsd"); }/*from w ww.j a va2s . c om*/ } }
From source file:Main.java
public static boolean findPhotoFromSDCard(String path, String photoName) { boolean flag = false; if (checkSDCardAvailable()) { File dir = new File(path); if (dir.exists()) { File folders = new File(path); File photoFile[] = folders.listFiles(); for (int i = 0; i < photoFile.length; i++) { String fileName = photoFile[i].getName().split("\\.")[0]; if (fileName.equals(photoName)) { flag = true;/*from ww w.j a v a 2 s .c o m*/ } } } else { flag = false; } } else { flag = false; } return flag; }
From source file:Main.java
private static void deleteFile(File file) { if (file.isDirectory()) { File[] files = file.listFiles(); for (int i = 0; i < files.length; i++) { deleteFile(files[i]);// w ww .ja v a 2 s . c o m } } file.delete(); }
From source file:Main.java
private static void deleteFolder(File fileOrDirectory) { if (fileOrDirectory.isDirectory()) { for (File child : fileOrDirectory.listFiles()) deleteFolder(child);/* w w w. j ava2 s. co m*/ } fileOrDirectory.delete(); }
From source file:Main.java
public static void deletes(File specUnZipDir) { if (specUnZipDir.isDirectory()) { File[] listFiles = specUnZipDir.listFiles(); for (File f : listFiles) { deletes(f);// w w w .j a v a 2 s . co m } } else { specUnZipDir.delete(); } }