public static String normalizePath ( String path ) { // remove double slashes & backslashes path = path . replace ( "//" , "/" ) ; path = path . replace ( "\\" , "/" ) ; // trim trailing slash from non-root path (ignoring windows drive) if ( path . length ( ) > 1 && path . endsWith ( "/" ) ) { path = path . substring ( 0 , path . length ( ) - 1 ) ; } return path ; }
This method is copied from Path .