public int divide ( char separator , Text [ ] parts ) { int pointer = pos ; int limit = pos + len ; int mark = pointer ; int count = 0 ; while ( pointer < limit ) { if ( chars [ pointer ] == separator ) { parts [ count ] . strain ( chars , mark , pointer - mark ) ; mark = pointer + 1 ; count ++ ; if ( count == parts . length - 1 ) { break ; } } pointer ++ ; } if ( limit > mark ) { parts [ count ] . strain ( chars , mark , limit - mark ) ; count ++ ; } return count ; }
Divides text into parts using given separator and writes results into the parts array .