List of utility methods to do File Path Get
File | getCanonicalFile(File file) Convert a file to canonical form. try { return new File(file.getCanonicalPath()); } catch (IOException e) { Log.util.debug("Could not create canonical path for %s: %s", file, e); return file; |
File | getDrive(File file) get Drive File drive = null; for (File dr : File.listRoots()) { if (file.getAbsolutePath().toLowerCase() .startsWith(dr.getAbsolutePath().toLowerCase())) { drive = dr; break; return drive; |
int | getPathLastIndex(String fileName) get Path Last Index int point = fileName.lastIndexOf('/'); if (point == -1) { point = fileName.lastIndexOf('\\'); return point; |
int | getPathLastIndex(String fileName, int fromIndex) get Path Last Index int point = fileName.lastIndexOf('/', fromIndex); if (point == -1) { point = fileName.lastIndexOf('\\', fromIndex); return point; |
File | getRoot(File file) Returns the filesystem root for file. Check.arg().notNull(file); if (!file.exists()) throw new IllegalArgumentException("file = " + file.getPath() + " is a non-existent path"); file = file.getCanonicalFile(); for (File parent = file.getParentFile(); parent != null; parent = file .getParentFile()) { file = parent; ... |