Here you can find the source of rightPad(StringBuilder pStringBuilder, int pLength, char pChar)
Parameter | Description |
---|---|
pStringBuilder | The StringBuffer object to pad. |
pLength | The length to pad to. |
pChar | The character to pad with. |
public static StringBuilder rightPad(StringBuilder pStringBuilder, int pLength, char pChar)
//package com.java2s; //License from project: Open Source License public class Main { /**/*ww w . j a v a 2 s . c o m*/ * Similar to the Oracle rpad command. Right pads a string. * * @param pStringBuilder The StringBuffer object to pad. * @param pLength The length to pad to. * @param pChar The character to pad with. * @return StringBuffer the chomped string. */ public static StringBuilder rightPad(StringBuilder pStringBuilder, int pLength, char pChar) { while (pStringBuilder.length() < pLength) { pStringBuilder.append(pChar); } return pStringBuilder; } /** * Similar to the Oracle rpad command. Right pads a string. * * @param pString The String object to pad. * @param pLength The length to pad to. * @param pChar The character to pad with. * @return String the padded string. */ public static String rightPad(String pString, int pLength, char pChar) { return rightPad(new StringBuilder(pString), pLength, pChar).toString(); } /** * Similar to the Oracle rpad command. Right pads a string. * * @param pString The String object to pad. * @param pLength The length to pad to. * @return String the padded string. */ public static String rightPad(String pString, int pLength) { return rightPad(new StringBuilder(pString), pLength, ' ').toString(); } }