Here you can find the source of formatHexStr(int width, String hexStr)
public static String formatHexStr(int width, String hexStr)
//package com.java2s; //License from project: Open Source License public class Main { public static String formatHexStr(int width, String hexStr) { if (hexStr.length() >= width) { return hexStr.substring(hexStr.length() - width); }//w w w .j a v a 2 s. c o m StringBuffer sb = new StringBuffer(); for (int i = 0; i < width - hexStr.length(); i++) { sb.append("0"); } sb.append(hexStr); return sb.toString(); } }