public static String normalizePath ( String path ) { // Replace any occurance of a backslash ("\") with a slash ("/"). // NOTE: Both String and Pattern escape backslash, so need four backslashes to find one. // NOTE: No longer replace multiple backslashes with one slash, which allows for UNC pathnames (Windows LAN addresses). // Was path.replaceAll( "\\\\+", "/"); String newPath = path . replaceAll ( "\\\\" , "/" ) ; // Remove trailing slashes. while ( newPath . endsWith ( "/" ) && ! newPath . equals ( "/" ) ) newPath = newPath . substring ( 0 , newPath . length ( ) - 1 ) ; return newPath ; }
Normalize the given path so that it can be used in the creation of a CrawlableDataset . This method can be used on absolute or relative paths .