public File getAbsoluteFile() { String absPath = getAbsolutePath(); return new File(absPath, fs.prefixLength(absPath)); }
public File getCanonicalFile() throws IOException { String canonPath = getCanonicalPath(); return new File(canonPath, fs.prefixLength(canonPath)); }
public File(String pathname) { if (pathname == null) throw new NullPointerException(); this.path = fs.normalize(pathname); this.prefixLength = fs.prefixLength(this.path); }
public File(URI uri) { if (!uri.isAbsolute()) throw new IllegalArgumentException("URI is not absolute"); if (uri.isOpaque()) throw new IllegalArgumentException("URI is not hierarchical"); String scheme = uri.getScheme(); if ((scheme == null) || !scheme.equalsIgnoreCase("file")) throw new IllegalArgumentException("URI scheme is not \"file\""); if (uri.getAuthority() != null) throw new IllegalArgumentException("URI has an authority component"); if (uri.getFragment() != null) throw new IllegalArgumentException("URI has a fragment component"); if (uri.getQuery() != null) throw new IllegalArgumentException("URI has a query component"); String p = uri.getPath(); if (p.equals("")) throw new IllegalArgumentException("URI path component is empty"); p = fs.fromURIPath(p); if (File.separatorChar != '/') p = p.replace('/', File.separatorChar); this.path = fs.normalize(p); this.prefixLength = fs.prefixLength(this.path); }
public File(File parent, String child) { if (child == null) throw new NullPointerException(); if (parent != null) { this.path = fs.resolve(parent.path.equals("") ? fs.getDefaultParent() : parent.path, fs.normalize(child)); } else { this.path = fs.normalize(child); } this.prefixLength = fs.prefixLength(this.path); }
/** * The FileSystem object representing the platform's local file system. */ private static final FileSystem fs = DefaultFileSystem.getFileSystem(); // Snip. public File(File parent, String child) { if (child == null) { throw new NullPointerException(); } if (parent != null) { if (parent.path.equals("")) { this.path = fs.resolve(fs.getDefaultParent(), fs.normalize(child)); } else { this.path = fs.resolve(parent.path, fs.normalize(child)); } } else { this.path = fs.normalize(child); } this.prefixLength = fs.prefixLength(this.path); }
public File(String parent, String child) { if (child == null) throw new NullPointerException(); if (parent != null) { this.path = fs.resolve(parent.equals("") ? fs.getDefaultParent() : fs.normalize(parent), fs.normalize(child)); } else { this.path = fs.normalize(child); } this.prefixLength = fs.prefixLength(this.path); }