private String parseUncRoot ( String path , String original ) { Matcher uncMatcher = UNC_ROOT . matcher ( path ) ; if ( uncMatcher . find ( ) ) { String host = uncMatcher . group ( 2 ) ; if ( host == null ) { throw new InvalidPathException ( original , "UNC path is missing hostname" ) ; } String share = uncMatcher . group ( 3 ) ; if ( share == null ) { throw new InvalidPathException ( original , "UNC path is missing sharename" ) ; } return path . substring ( uncMatcher . start ( ) , uncMatcher . end ( ) ) ; } else { // probably shouldn't ever reach this throw new InvalidPathException ( original , "Invalid UNC path" ) ; } }
Parse the root of a UNC - style path throwing an exception if the path does not start with a valid UNC root .