public static String [ ] splitLongString ( String str , char separator ) { int len = ( str == null ) ? 0 : str . length ( ) ; if ( str == null || len == 0 ) { return ArrayUtils . EMPTY_STRING_ARRAY ; } int oldPos = 0 ; ArrayList list = new ArrayList ( ) ; int pos = str . indexOf ( separator ) ; while ( pos >= 0 ) { list . add ( substring ( str , oldPos , pos ) ) ; oldPos = ( pos + 1 ) ; pos = str . indexOf ( separator , oldPos ) ; } list . add ( substring ( str , oldPos , len ) ) ; return ( String [ ] ) list . toArray ( ArrayUtils . EMPTY_STRING_ARRAY ) ; }
Split a string into an array of strings arround a character separator . This function will be efficient for longer strings