Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using Strings.padEnd() API.
package com.bethecoder.tutorials.guava.base_tests; import com.google.common.base.Strings; public class StringPadEndTest { /** * @param args */ public static void main(String[] args) { String str = Strings.padEnd("6", 4, '*'); System.out.println(str); str = Strings.padEnd("68", 4, '*'); System.out.println(str); str = Strings.padEnd("", 4, '*'); System.out.println(str); str = Strings.padEnd("2010", 4, '*'); System.out.println(str); str = Strings.padEnd("20100", 4, '*'); System.out.println(str); } }
6*** 68** **** 2010 20100