List of usage examples for java.io File getPath
public String getPath()
From source file:Main.java
public static String getExtension(File file) { return getExtension(file.getPath()); }
From source file:Main.java
public static String combine(final String path1, final String path2) { final File file1 = new File(path1); final File file2 = new File(file1, path2); return file2.getPath(); }
From source file:DirTree.java
/** doFile - process one regular file. */ private static void doFile(File f) { System.out.println("f " + f.getPath()); }
From source file:Main.java
public static String getFileExtension(File file) { return getFileExtension(file.getPath()); }
From source file:Main.java
/** * Recursively list all files within a directory and sub directories * @param f File to search/*from ww w .j a v a 2s .c om*/ * @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 long getUsableSpace(File path) { final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:Main.java
/** * @return the number of bytes available on the filesystem rooted at the given File *///from ww w . jav a2 s . c om public static long getAvailableBytes(File root) { StatFs stat = new StatFs(root.getPath()); long availableBlocks = (long) stat.getAvailableBlocks() - 4; return stat.getBlockSize() * availableBlocks; }
From source file:Main.java
/** * Returns true if any {@code roots} combined with {@code rootSuffix} equals {@code canonicalPath} * @param roots to check//from w w w. ja v a2 s . c o m * @param rootSuffix to add to the end of each {@code roots} when evaluating * @param canonicalPath to match * @return true if any {@code roots} combined with {@code rootSuffix} equals {@code canonicalPath} */ private static boolean reachedRoot(File[] roots, String rootSuffix, String canonicalPath) { for (File root : roots) { if (canonicalPath.equals(root.getPath() + rootSuffix)) { return true; } } return false; }
From source file:Main.java
/** * @return the number of bytes available on the filesystem rooted at the * given File//from w w w . j a v a 2 s . c om */ public static long getAvailableBytes(File root) { StatFs stat = new StatFs(root.getPath()); // put a bit of margin (in case creating the file grows the system by a // few blocks) long availableBlocks = (long) stat.getAvailableBlocks() - 4; return stat.getBlockSize() * availableBlocks; }
From source file:Main.java
static public StatFs getStatFs() { File path = Environment.getDataDirectory(); return new StatFs(path.getPath()); }