question: private String collapseSlashes ( String path ) { int length = path . length ( ) ; if ( length < 3 ) return path ; if ( path . indexOf ( "//" , 1 ) == - 1 ) return path ; char [ ] result = new char [ path . length ( ) ] ; int count = 0 ; boolean hasPrevious = false ; char [ ] characters = path . toCharArray ( ) ; for ( int index = 0 ; index < characters . length ; index ++ ) { char c = characters [ index ] ; if ( c == SEPARATOR ) { if ( hasPrevious ) { if ( device == null && index == 1 ) { result [ count ] = c ; count ++ ; } } else { hasPrevious = true ; result [ count ] = c ; count ++ ; } } else { hasPrevious = false ; result [ count ] = c ; count ++ ; } } return new String ( result , 0 , count ) ; }
target:  Removes duplicate slashes from the given path, with the exception of leading double slash which represents a UNC path.