Display specific length string without truncating word in Java
June 25th, 2009No Comments
If you want to display substring of text and don’t want to truncate word in a substring, then you can use below method to fulfill your requirement.
String str="";
int limit=0;
limit=end;
if(text.length()!=0 && text!=""){
String substr=text.substring(end,end+1);
if(substr!=""){
while(!substr.equals("")){
substr=text.substring(limit,++limit);
substr=substr.trim();
}
}
str=text.substring(start,limit);
}
return str;
}