trim in java change length of string code example Example: java trim string to length string.abbreviate(desired_length);