trim a string to a certain length java code example Example: java trim string to length string.abbreviate(desired_length);