Java String Pad Right rightPad(String originalText, int length, char fillChar)

Here you can find the source of rightPad(String originalText, int length, char fillChar)

Description

right Pad

License

Open Source License

Declaration

public static String rightPad(String originalText, int length, char fillChar) 

Method Source Code

//package com.java2s;
/**//from  w  w  w .j av a 2  s.  c o m
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * This program 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, version 3 of the License.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright (C) 2009 SACI Inform?tica Ltda.
 */

public class Main {
    public static String rightPad(String originalText, int length, char fillChar) {
        StringBuilder sb = new StringBuilder();
        length = length - originalText.length();
        sb.append(originalText);
        for (int i = 0; i < length; i++) {
            sb.append(fillChar);
        }
        return sb.toString();
    }
}

Related

  1. rightPad(String in, int len, String pad)
  2. rightPad(String input, char padding, int length)
  3. rightPad(String input, int length, char pad)
  4. rightPad(String inStr, int length, char paddingChar)
  5. rightPad(String original, int length, char padChar)
  6. rightPad(String ret, int limit)
  7. rightPad(String s, int length)
  8. rightPad(String s, int length)
  9. rightPad(String s, int length)