Here you can find the source of valueOfString(String str, int len)
private static String valueOfString(String str, int len)
//package com.java2s; public class Main { private static String valueOfString(String str, int len) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < len - str.length(); i++) { sb.append("0"); }//from w w w. j a v a 2 s . c o m return (sb.length() == 0) ? (str) : (sb.toString() + str); } }