[java] How to remove the last character from a string?