Text implements CharSequence { public Collection<Text> split(char separator) { int pointer = pos; int limit = pos + len; int mark = pointer; ArrayList<Text> tokens = new ArrayList<Text>(); while (pointer < limit) { if (chars[pointer] == separator) { tokens.add(new Text(chars, mark, pointer - mark)); mark = pointer + 1; } pointer++; } tokens.add(new Text(chars, mark, limit - mark)); return tokens; } 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 testSplit() { Text t1 = new Text("test test1 test2"); Collection<Text> tokens = t1.split(' '); assertEquals(3, tokens.size()); Iterator<Text> i = tokens.iterator(); Text t = i.next(); assertEquals("test", t.toString()); t = i.next(); assertEquals("test1", t.toString()); t = i.next(); assertEquals("test2", t.toString()); }
@Test public void testSplitExecutionTime() { Text t1 = new Text("test test1 test2"); long s = System.nanoTime(); for (int i = 0; i < 1000; i++) { Collection<Text> tokens = t1.split(' '); } long f = System.nanoTime(); System.out.println("Split execution time=" + (f-s)); assertTrue("Too slow", 15000000 > (f-s)); }