Here you can find the source of rightPad(String inStr, int length, char paddingChar)
Parameter | Description |
---|---|
inStr | Input string |
length | Padding length |
paddingChar | Padding character |
public static String rightPad(String inStr, int length, char paddingChar)
//package com.java2s; public class Main { /**//from w w w .java2s . com * Right padding the string with the specified padding character upto the specified length. * @param inStr Input string * @param length Padding length * @param paddingChar Padding character * @return Padding string */ public static String rightPad(String inStr, int length, char paddingChar) { if (inStr.length() == length) return inStr; StringBuffer outStr = new StringBuffer(); outStr.append(inStr); for (int i = inStr.length(); i < length; i++) { outStr.append(paddingChar); } return outStr.toString(); } /** * Converts object to a string.<br> * If object is null then return null * * @param obj * @return */ public static String toString(Object obj) { if (null == obj) { return null; } else { return obj.toString(); } } }