/** * Removes any redundant {@code "."}, {@code ".."} directories from the * path name. * * @return The normalized path string denoting the same file or * directory as this instance. */ public String getNormalizedPath() { return Paths.normalize(getPath(), separatorChar); }
/** * Similar to {@link #getAbsolutePath()}, but removes any redundant * {@code "."} and {@code ".."} directories from the path name. * The result is similar to {@link #getCanonicalPath()}, but symbolic * links are not resolved. * This may be useful if {@code getCanonicalPath()} throws an * IOException. * * @return The normalized absolute path string denoting the same file or * directory as this instance. * @see #getCanonicalPath() * @see #getNormalizedPath() */ public String getNormalizedAbsolutePath() { return Paths.normalize(getAbsolutePath(), separatorChar); }
/** * This convenience method simply returns the canonical form of this * abstract path or the normalized absolute form if resolving the * prior fails. * * @return The canonical or absolute path of this file as a * {@code String} instance. */ public String getCanOrAbsPath() { try { return getCanonicalPath(); } catch (IOException ex) { return Paths.normalize(getAbsolutePath(), separatorChar); } }
private void assertNormalize( final String expected, final String path, final char separatorChar) { assertEquals(URI .create(path.replace(separatorChar, '/')) .normalize() .toString() .replace('/', separatorChar), expected); final String result = Paths.normalize(path, separatorChar); assertEquals(expected, result); assertTrue(!result.equals(path) || result == path); // mind contract! } }
return controller; final File file = this.file; final String path = Paths.normalize(file.getPath(), separatorChar); final FsScheme scheme = detector.getScheme(path);