private String [ ] splitInTwo ( String text ) { Matcher matcher = LINE_SEPARATOR . matcher ( text ) ; while ( matcher . find ( ) ) { int start = matcher . start ( ) ; if ( start > 0 && start < text . length ( ) ) { String segment = text . substring ( 0 , start ) ; if ( segment . trim ( ) . length ( ) > 0 ) return new String [ ] { text . substring ( 0 , start ) , text . substring ( start ) } ; } } return new String [ ] { text } ; }
Break a text segment apart into two at the first line delimiter which has non - whitespace characters before it .