Java tutorial
//package com.java2s; public class Main { private static String padHex(String s, int i) { StringBuffer tmpBuffer = new StringBuffer(); if (s.length() < i) { for (int j = 0; j < i - s.length(); j++) { tmpBuffer.append('0'); } } return tmpBuffer.toString(); } }