Here you can find the source of bin2Hex(String bin)
public static String bin2Hex(String bin)
//package com.java2s; //License from project: Open Source License public class Main { public static String bin2Hex(String bin) { int intVal = parseBin(bin); return normalizeNumber(Integer.toHexString(intVal), bin.length() / 4); }/* w ww .ja v a2s .com*/ public static int parseBin(String bin) { try { return (int) Long.parseLong("0" + bin, 2); } catch (Exception e) { e.printStackTrace(); } return 0; } private static String normalizeNumber(String ret, int size) { int addCount = size - ret.length(); if (addCount > 0) { for (int i = 0; i < addCount; i++) { ret = "0" + ret; } } else { ret = ret.substring(ret.length() - size, ret.length()); } return ret; } }