List of usage examples for java.io File isFile
public boolean isFile()
From source file:Main.java
private static void RecursionDeleteFile(File file) { if (file.isFile()) { file.delete();//from ww w. j a v a 2 s . com return; } if (file.isDirectory()) { File[] childFile = file.listFiles(); if (childFile == null || childFile.length == 0) { file.delete(); return; } for (File f : childFile) { RecursionDeleteFile(f); } file.delete(); } }
From source file:Main.java
public static void RecursionDeleteFile(File file) { if (file.isFile()) { file.delete();//from w w w . j ava2s . com return; } if (file.isDirectory()) { File[] childFile = file.listFiles(); if (childFile == null || childFile.length == 0) { file.delete(); return; } for (File f : childFile) { RecursionDeleteFile(f); } file.delete(); } }
From source file:Main.java
public static boolean deleteFile(String filePath) { File file = new File(filePath); if (file.isFile() && file.exists()) { return file.delete(); }// w ww. j a v a 2 s.com return false; }
From source file:Main.java
/** * Recursively list all files within a directory and sub directories * @param f File to search/* w w w .ja v a 2 s .com*/ * @param files List of files found */ public static void listFiles(File f, ArrayList<File> files) { File[] fs = f.listFiles(); for (File file : fs) { if (file.isFile() && file.getPath().endsWith(".jar")) { files.add(file); } else if (file.isDirectory()) { listFiles(file, files); } } }
From source file:Main.java
public static void delete(File file) { if (file.isFile()) { file.delete();/*from w ww . j ava 2 s . c o m*/ return; } if (file.isDirectory()) { File[] childFile = file.listFiles(); if (childFile == null || childFile.length == 0) { file.delete(); return; } for (File f : childFile) { delete(f); } file.delete(); } }
From source file:Main.java
public static void deleteFile(File file) { if (file.isFile()) { file.delete();//from w w w. j a v a2s . c o m return; } if (file.isDirectory()) { File[] childFile = file.listFiles(); if (childFile == null || childFile.length == 0) { file.delete(); return; } for (File f : childFile) { deleteFile(f); } file.delete(); } }
From source file:Main.java
private static long getDirSize(File dir) { long size = 0; File[] files = dir.listFiles(); for (File file : files) { if (file.isFile()) { size += file.length();// w w w . ja va 2 s . c om } } return size; }
From source file:Main.java
public static boolean DeleteFile(File file) { if (file.isFile()) { return file.delete(); }//from w w w . jav a 2 s. com if (file.isDirectory()) { File[] childFile = file.listFiles(); if (childFile == null || childFile.length == 0) { return file.delete(); } for (File f : childFile) { DeleteFile(f); } return file.delete(); } return false; }
From source file:edu.uci.ics.asterix.test.aql.AQLTestSuite.java
public static Test suite() throws ParseException, UnsupportedEncodingException, FileNotFoundException { File testData = new File(AQLTS_PATH); File[] queries = testData.listFiles(); TestSuite testSuite = new TestSuite(); for (File file : queries) { if (file.isFile()) { testSuite.addTest(new AQLTestCase(file)); }// w w w . j a va2 s.c om } testData = new File(AQLTS_SQL_LIKE_PATH); queries = testData.listFiles(); for (File file : queries) { if (file.isFile()) { testSuite.addTest(new AQLTestCase(file)); } } return testSuite; }
From source file:Main.java
public static long folderSize(File directory) { long length = 0; File[] files = directory.listFiles(); if (files != null) for (File file : files) if (file.isFile()) length += file.length(); else//www .ja va 2 s.co m length += folderSize(file); return length; }