Java String Pad Right rightPad(String value, int tamanho, String pad)

Here you can find the source of rightPad(String value, int tamanho, String pad)

Description

Adds pad on the right side to complete the size

License

Open Source License

Parameter

Parameter Description
value - text to add pad
size - size to completed pad
pad - valur to add

Return

string with pad

Declaration

public static String rightPad(String value, int tamanho, String pad) 

Method Source Code

//package com.java2s;
/*/*from   w w  w.ja  va  2s . c  o m*/
 *     @(#)StringUtils.java   1.4 10/11/22
 * 
 *   Copyright (c) 2010 Felipe Priuli
 *
 *   This file is part of OpenSutils-Br4J.
 *
 *   OpenSutils-Br4J is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, any later version.
 *
 *   OpenSutils-Br4J is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
*/

public class Main {
    /**
     * Adds pad on the right side to complete the size
     * @param    value - text to add pad
     * @param    size - size to completed pad
     * @param    pad - valur to add
     * @return    string with pad
     */
    public static String rightPad(String value, int tamanho, String pad) {
        if (value.length() < tamanho && !pad.isEmpty()) {
            return rightPad(value.concat(pad), tamanho, pad);
        }
        return value;
    }
}

Related

  1. rightPad(String strInput, int intLength)
  2. rightPad(String targetStr, char appendChar, int length)
  3. rightPad(String toPad, int totalLength)
  4. rightPad(String value, int length)
  5. rightPad(String value, int makeLength, char paddingCharacter)
  6. rightPad(StringBuilder pStringBuilder, int pLength, char pChar)
  7. rightPadded(String src, int len)
  8. rightPaddedBaseString(String bases, int length)
  9. rightPaddedString(String string, int length, char paddingChar)