Created
January 12, 2015 11:05
-
-
Save bashizip/b028b3cc6df8dbb4ad6b to your computer and use it in GitHub Desktop.
Trim text to display preserving whole word at end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String textToDisplay=textToTrim.substring(0,(textToTrim.length() > 120) ? 120 : textToTrim.length()); | |
if (not.getQuestionMessage().lastIndexOf(' ') != textToDisplay.length() &&textToDisplay.length()!=textToTrim().length()) { | |
textToDisplay = textToDisplay + textToTrim.substring(textToDisplay.length(),textToTrim.indexOf(" ", textToDisplay.length()-1))+ " ..."; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment