/** * Removes any <code>"."</code> and <code>".."</code> directories from the * path wherever possible. * * @param file The file instance which's path is to be normalized. * @return <code>file</code> if it was already in normalized form. Otherwise, an object which's * runtime class is guaranteed to be <code>java.io.File</code>. */ public static java.io.File normalize(final java.io.File file) { final String path = file.getPath(); final String newPath = Paths.normalize(path, File.separatorChar); return newPath != path // mind contract of Paths.normalize! ? new java.io.File(newPath) : file; }