Here you can find the source of rightPad(String originalText, int length, char fillChar)
public static String rightPad(String originalText, int length, char fillChar)
//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(); } }