public static String getAllButLastSegment ( final List < PathSegment > segments ) { if ( segments . isEmpty ( ) ) { return "" ; } return segments . subList ( 0 , segments . size ( ) - 1 ) . stream ( ) . map ( PathSegment :: getPath ) . collect ( joining ( "/" ) ) ; }
From a list of segments use all but the last item joined in a String .