Here you can find the source of leftPadding(String orgStr, String addStr, int strLength)
public static String leftPadding(String orgStr, String addStr, int strLength)
//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; } } }