[java] Calculate the display width of a string in Java