Java Binary to Hex bin2hex(String bin)

Here you can find the source of bin2hex(String bin)

Description

binhex

License

Open Source License

Declaration

public static String bin2hex(String bin) 

Method Source Code

//package com.java2s;

public class Main {

    public static String bin2hex(String bin) {
        char[] digital = "0123456789ABCDEF".toCharArray();
        StringBuffer sb = new StringBuffer("");
        byte[] bs = bin.getBytes();
        int bit;//from w w w  .j a v  a  2 s .c om
        for (int i = 0; i < bs.length; i++) {
            bit = (bs[i] & 0x0f0) >> 4;
            sb.append(digital[bit]);
            bit = bs[i] & 0x0f;
            sb.append(digital[bit]);
        }
        return sb.toString();
    }
}

Related

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