Here you can find the source of binToHex(String sBinString)
public static String binToHex(String sBinString)
//package com.java2s; public class Main { public static String binToHex(String sBinString) { String sHexString = ""; String sTemp = ""; while (sBinString.length() >= 4) { sTemp = sBinString.substring(0, 4); sBinString = sBinString.substring(4, sBinString.length()); sHexString += Integer.toHexString(Integer.parseInt(sTemp, 2)); }/*from w w w .j a v a 2 s .c om*/ if (sBinString.length() > 1) { for (int i = 0; i < 4 - sBinString.length(); i++) { sBinString = "0" + sBinString; } sHexString += Integer.toHexString(Integer.parseInt(sBinString, 2)); } return sHexString; } }