How about substring(0,10) or substring(0,11) depending on whether index 10 is included or not? You would have to check length() >= index , though.
An alternative could be org.apache.commons.lang.StringUtils.substring("your string", 0, 10);
Thomas
source share