Here you can find the source of rightPad(String input, char padding, int length)
public static String rightPad(String input, char padding, int length)
//package com.java2s; //License from project: LGPL public class Main { public static String rightPad(String input, char padding, int length) { if (nullOrEmpty(input)) input = ""; if (input.length() >= length) return input; String padString = createPad(padding, length - input.length()); return input.concat(padString); }//from w ww . j av a2 s. co m public static boolean nullOrEmpty(String s) { return (s == null) ? true : "".equals(s.trim()); } public static String createPad(char padding, int length) { StringBuilder out = new StringBuilder(); for (int repeat = 0; repeat < length; repeat++) out.append(padding); return out.toString(); } public static String trim(String s) { return emptyIfNull(s).trim(); } public static String emptyIfNull(String s) { return (s == null) ? "" : s; } }