Text implements CharSequence { public void trim() { try { while (len>0 && chars[pos] == ' ') { pos++; len--; } while (len>0 && (chars[pos + len - 1] == ' ' || chars[pos + len - 1] == '\n' || chars[pos + len - 1] == '\r')) { len--; } } catch(Exception e) { System.out.println("len:" + len + ",pos:" + pos); } } 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 testTrim() { Text t1 = new Text(" test "); t1.trim(); assertEquals("test", t1.toString()); }