private static int strAppender ( String [ ] _text , StringBuilder _sbResult , int _beginIdx , int _len ) { if ( _text == null || _sbResult == null ) { return - 1 ; } if ( _beginIdx > _text . length ) { return _text . length ; } int i = _beginIdx ; for ( i = _beginIdx ; i < _text . length ; i ++ ) { // current token length + current buffer length if ( _sbResult . length ( ) < _len ) { int condition = _text [ i ] . length ( ) + _sbResult . length ( ) ; boolean firstOrLastToken = true ; if ( i <= _text . length - 1 && _sbResult . length ( ) > 0 ) { // add one char (for trailing space) if result is not empty and we are not on the first token condition += 1 ; // + 1 (for space) firstOrLastToken = false ; } if ( condition <= _len ) { if ( ! firstOrLastToken ) { // append a space if result is not empty and we are not on the first token _sbResult . append ( " " ) ; } _sbResult . append ( _text [ i ] ) ; } else { i -= 1 ; break ; } } else { if ( i > _beginIdx ) { i -= 1 ; } break ; } } return i ; }
Internally used by smartStringSplit to recombine the string until the expected length is reached .