List of usage examples for java.io File isFile
public boolean isFile()
From source file:Main.java
public static boolean fileExists(String s) { File file = new File(s); boolean flag; if (file.isFile() && file.exists()) flag = true;//from w w w . j av a 2s. com else flag = false; return flag; }
From source file:Main.java
public static void defileFile(File file) { if (file.isFile()) { file.delete();/* w ww . j ava 2s .c o m*/ return; } if (file.isDirectory()) { File[] childFiles = file.listFiles(); if (childFiles == null || childFiles.length == 0) { file.delete(); return; } for (File f : childFiles) { defileFile(f); } file.delete(); } }
From source file:Main.java
public static void deleteDir() { File dir = new File(SDPATH); if (dir == null || !dir.exists() || !dir.isDirectory()) return;//from w w w . j a v a2 s.c o m for (File file : dir.listFiles()) { if (file.isFile()) file.delete(); else if (file.isDirectory()) deleteDir(); } dir.delete(); }
From source file:Main.java
public static long getFileSize(String path) { if (TextUtils.isEmpty(path)) { return -1; }/*from ww w.ja v a 2 s .com*/ File file = new File(path); return (file.exists() && file.isFile() ? file.length() : -1); }
From source file:Main.java
private static void deleteDir(File dir) { File[] files = dir.listFiles(); if (files != null & files.length > 0) { for (File file : files) { if (file.isFile()) { file.delete();/*from ww w . ja v a 2s .c o m*/ } else if (file.isDirectory()) { deleteDir(file); } } } dir.delete(); }
From source file:Main.java
public static List<String> getFolderContent(String folderDir) { File file = new File(folderDir); List<String> filesPath = new ArrayList<>(); if (!file.exists()) { } else {/*from w ww . j a va2 s.com*/ for (File f : file.listFiles()) { if (f.isFile()) { filesPath.add(f.getPath()); } } } return filesPath; }
From source file:Main.java
public static boolean DoesFileExist(String path) { if (path == null) return false; if (path.trim().isEmpty()) return false; File file = new File(path.trim()); return file.exists() && file.isFile(); }
From source file:Main.java
public static boolean fileAvaliable(String path) { boolean flag = false; if (!TextUtils.isEmpty(path)) { File file = new File(path); flag = file.exists() && file.isFile() && file.length() > 0; }/*from ww w . j a v a 2s . c om*/ return flag; }
From source file:Main.java
public static long getFileSize(Context context, String filePath) { if (context != null && !TextUtils.isEmpty(filePath)) { File f = new File(filePath); if (f.exists() && f.isFile()) { return f.length(); }// www . j av a 2 s .c o m } return -1l; }
From source file:Main.java
public static File[] getSavegames(File folder) { File[] files = folder.listFiles(); ArrayList<File> saveFiles = new ArrayList<File>(); if (files != null) { for (final File fileEntry : files) { if (fileEntry.isFile()) { if (fileEntry.getName().toLowerCase().endsWith(".lsd")) { saveFiles.add(fileEntry); }/*from ww w . ja va 2s . c o m*/ } } } return saveFiles.toArray(new File[saveFiles.size()]); }