List of usage examples for java.io File getPath
public String getPath()
From source file:Main.java
public static void File_iterateFiles(String dir) { File f = new File(dir); File[] files = f.listFiles(); if (null != files) { for (File ff : files) { if (ff.isDirectory()) { File_iterateFiles(ff.getPath()); } else { //TODO }/*from www. j av a2s . c o m*/ } } }
From source file:Main.java
@SuppressWarnings("deprecation") public static long getTotalExternalMemorySize() { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long totalBlocks = stat.getBlockCount(); return totalBlocks * blockSize; } else {//from w ww.ja v a2s.c om return -1; } }
From source file:Main.java
@SuppressWarnings("deprecation") public static long getAvailableExternalMemorySize() { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; } else {/*from www . j a v a2 s . c o m*/ return -1; } }
From source file:Main.java
public static String getTotalExternalMemorySize(Context context) { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long totalBlocks = stat.getBlockCount(); return Formatter.formatFileSize(context, totalBlocks * blockSize); } else {/*from w w w .j a v a2 s . c o m*/ return "ERROR"; } }
From source file:Main.java
public static long getAvailableExternalMemorySize() { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; }
From source file:Main.java
public static String getAvailableExternalMemorySize(Context context) { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return Formatter.formatFileSize(context, availableBlocks * blockSize); } else {/*from www . j a va2 s . com*/ return "ERROR"; } }
From source file:Main.java
/** * Try to find the {@link Document} associated with a certain language * directory path. In case nothing is found, null is returned. * /* w w w . jav a2 s. c o m*/ * @param map * {@link Map} in which the search will be made. * @param languageDirectory * Directory holding the path to be compared, in order to find * the {@link Document} in the given {@link Map}. This Object is * updated with a reference to the object in the {@link Map}. * * @return {@link Document} element associated, in case a match is * successful. */ private static Document findDocumentByLanguageDirectory(Map<File, Document> map, File languageDirectory) { Document document = null; Set<File> languageFolders = map.keySet(); if (languageFolders != null) { for (File languageFolder : languageFolders) { if (languageFolder.getPath().equals(languageDirectory.getPath())) { document = map.get(languageFolder); languageDirectory = languageFolder; break; } } } return document; }
From source file:net.grinder.lang.Lang.java
/** * Get {@link Lang} enum by the given file's name. * * @param file file// ww w. j ava2 s. co m * @return {@link Lang} enum value */ public static Lang getByFileName(File file) { return getByFileName(file.getPath()); }
From source file:Main.java
/** * @return the root of the filesystem containing the given path *///w ww. ja v a 2s. c o m public static File getFilesystemRoot(String path) { File cache = Environment.getDownloadCacheDirectory(); if (path.startsWith(cache.getPath())) { return cache; } File external = Environment.getExternalStorageDirectory(); if (path.startsWith(external.getPath())) { return external; } throw new IllegalArgumentException("Cannot determine filesystem root for " + path); }
From source file:com.norconex.commons.wicket.markup.html.filesystem.FileSystemTreeProvider.java
public static boolean isUserHomeRoot(File file) { return file.getPath().equals(SystemUtils.USER_HOME); }