List of usage examples for java.io File isDirectory
public boolean isDirectory()
From source file:Main.java
public static String getExternalStorage() { String extSdCardStr = System.getenv("SECONDARY_STORAGE"); if (extSdCardStr != null) { File extSdCardFile = new File(extSdCardStr); if (extSdCardFile.isDirectory()) return extSdCardFile.getAbsolutePath(); }// w ww . j a v a 2 s . co m return ""; }
From source file:Main.java
public static Boolean externalStorageExists() { String extSdCardStr = System.getenv("SECONDARY_STORAGE"); if (extSdCardStr != null) { File extSdCardFile = new File(extSdCardStr); return (extSdCardFile.isDirectory()); }//from w ww. j a v a 2s . c o m return false; }
From source file:Main.java
public static List<File> getListFiles(File parentDir) { ArrayList<File> inFiles = new ArrayList<File>(); File[] files = parentDir.listFiles(); for (File file : files) { if (file.isDirectory()) { inFiles.addAll(getListFiles(file)); } else {/* w w w.j a v a2s. co m*/ inFiles.add(file); } } return inFiles; }
From source file:Main.java
/** * Gets the opf file name.// ww w.j a v a2 s . c o m * * @param path the folder contains file opf. * @return the opf file name */ public static String getOpfFileName(String path) { String fileName = null; File folder = new File(path); if (folder.isDirectory()) { File[] listOfFiles = folder.listFiles(); if (listOfFiles != null) { for (File file : listOfFiles) { if (file.isFile() && file.getName().endsWith(".opf")) { fileName = file.getName(); break; } } } } return fileName; }
From source file:Main.java
public static void DeleteBookmarkedHtmlResource(File fileOrDirectory) { try {//from w w w . j av a 2s .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 void reNameSuffix(File dir, String oldSuffix, String newSuffix) { if (dir.isDirectory()) { File[] listFiles = dir.listFiles(); for (int i = 0; i < listFiles.length; i++) { reNameSuffix(listFiles[i], oldSuffix, newSuffix); }// www .ja v a2 s. c o m } else { dir.renameTo(new File(dir.getPath().replace(oldSuffix, newSuffix))); } }
From source file:Main.java
public static String getPrivateFilePath(Context context, String yourAppPath) { String PATH = context.getFilesDir().getAbsolutePath() + yourAppPath; File file = new File(PATH); if (!(file.exists() && file.isDirectory())) { file.mkdirs();//from ww w. j av a2 s . c o m } return PATH; }
From source file:Main.java
public static void deleteFileByDirectory(File directory) { if (directory.exists() && directory.isDirectory()) { for (File file : directory.listFiles()) { file.delete();//from w w w .j av a 2 s . c o m } } }
From source file:Main.java
public static boolean deleteDir(File dir) { if (dir != null && dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { boolean success = deleteDir(new File(dir, children[i])); if (!success) { return false; }//from www.j av a 2 s.c o m } } return dir.delete(); }
From source file:Main.java
public static boolean isFirstRun(Context context) { String dirname = getDataDirectory(context) + "shared_prefs"; File dir = new File(dirname); return !(dir.exists() && dir.isDirectory()); }