public static String [ ] split ( String value ) { if ( value == null || "" . equals ( value ) ) { return EMPTY_STRING_ARRAY ; } int len = value . length ( ) ; List < String > list = new LinkedList <> ( ) ; boolean collectingSpace = true ; int start = 0 ; for ( int i = 0 ; i < len ; i ++ ) { char c = value . charAt ( i ) ; if ( c == ' ' || c == ' ' || c == ' ' || c == ' ' ) { if ( ! collectingSpace ) { list . add ( value . substring ( start , i ) ) ; collectingSpace = true ; } } else { if ( collectingSpace ) { start = i ; collectingSpace = false ; } } } if ( start < len ) { int end = len ; for ( int i = 1 ; len > i ; i ++ ) { char c = value . charAt ( len - i ) ; if ( c == ' ' || c == ' ' || c == ' ' || c == ' ' ) { end -- ; continue ; } break ; } list . add ( value . substring ( start , end ) ) ; } return list . toArray ( EMPTY_STRING_ARRAY ) ; }
Splits the argument on white space .