Java String Pad Left leftPadding(String orgStr, String addStr, int strLength)

Here you can find the source of leftPadding(String orgStr, String addStr, int strLength)

Description

left Padding

License

Open Source License

Declaration

public static String leftPadding(String orgStr, String addStr, int strLength) 

Method Source Code

//package com.java2s;
/**/* w ww.java 2s . c  o m*/
 * Copyright (c) 2011, yoomai.net. All rights reserved.
 * yoomai.cn. Use is subject to license terms.
 */

public class Main {

    public static String leftPadding(String orgStr, String addStr, int strLength) {
        if (orgStr.length() < strLength) {
            String padding = new String();
            int len = strLength - orgStr.length();
            for (int loop = 0; loop < len; loop++) {
                padding = padding + addStr;
            }
            padding = padding + orgStr;
            return padding;
        } else {
            return orgStr;
        }
    }
}

Related

  1. leftPadByteArray(byte[] source, int size)
  2. leftPadded(String src, int len)
  3. leftPaddedString(String string, int length, char paddingChar)
  4. leftPadding(final StringBuffer strBuf, final int bufLen, final char fill)
  5. leftPadding(String in, int count, char pad)
  6. leftPadInt(int number, int width)
  7. leftPadMultiline(String input, char padChar, int padWidth)
  8. leftPadString(String str, char pad, int length)
  9. leftPadString(String sValue, int iLength, String sPadString)