Text implements CharSequence { 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; } Text(); protected  Text(Text another);  Text(String s);  Text(int i);  Text(byte[] data, int pos, int len); void strain(byte[] data, int pos, int len); int length(); char charAt(int index); void copy(Text destination); void duplicate(Text destination); int divide(char separator, Text[] parts); int divide(char[] separators, Text[] parts); CharSequence subSequence(int start, int end); Text subtext(int start, int end); Text subtext(int start); Collection<Text> split(char separator); Collection<Text> split(Text separator); int indexOf(Text value); int indexOf(char value); void trim(); Text nextLine(); boolean hasMoreLines(); @Override boolean equals(Object other); @Override int hashCode(); boolean startsWith(Text pattern); @Override String toString(); int toInteger(); long toLong(); int hexToInteger(); void write(ByteBuffer buffer); void copyRemainder(Text other); boolean contains(char c);  }
@Test public void testDivide() { Text t1 = new Text("test test1 test2"); Text t2 = new Text(); Text t3 = new Text(); Text t4 = new Text(); int count = t1.divide(' ', new Text[] {t2,t3,t4}); assertEquals(3, count); assertEquals("test", t2.toString()); assertEquals("test1", t3.toString()); assertEquals("test2", t4.toString()); }