Java Binary to Hex binaryString2hexString(String bString)

Here you can find the source of binaryString2hexString(String bString)

Description

binary Stringhex String

License

LGPL

Declaration

public static String binaryString2hexString(String bString) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static String binaryString2hexString(String bString) {
        if (bString == null || bString.equals("") || bString.length() % 8 != 0)
            return null;
        StringBuffer tmp = new StringBuffer();
        int iTmp = 0;
        for (int i = 0; i < bString.length(); i += 4) {
            iTmp = 0;//from   www.ja v  a2 s  . c  o m
            for (int j = 0; j < 4; j++) {
                iTmp += Integer.parseInt(bString.substring(i + j, i + j + 1)) << (4 - j - 1);
            }
            tmp.append(Integer.toHexString(iTmp));
        }
        return tmp.toString();
    }
}

Related

  1. bin2hex(final byte[] base)
  2. bin2hex(int digit)
  3. bin2Hex(String bin)
  4. bin2hex(String bin)
  5. bin2hex(String str)
  6. binaryToHex(byte[] ba)
  7. binaryToHex(byte[] bytes)
  8. binaryToHex(byte[] data)
  9. binaryToHex(char[] binaryStr)