Here you can find the source of rightPaddedString(String string, int length, char paddingChar)
public static String rightPaddedString(String string, int length, char paddingChar)
//package com.java2s; //License from project: Open Source License public class Main { public static String rightPaddedString(String string, int length, char paddingChar) { if (string.length() > length) { System.err.println("WARNING: String to pad is longer than expected length. Return original string."); return string; }/*from w ww . ja va2 s . co m*/ if (string.length() == length) return string; return string.concat(String.format("%0" + (length - string.length()) + "d", 0).replace('0', paddingChar)); } }