Software Development, Agile Practices, Lean Thinking, Music
[ start | index | login or register ]
start > toHexString()

toHexString()

Created by brandon. Last edited by brandon, 3 years and 152 days ago. Viewed 669 times. #2
[diff] [history] [edit] [rdf]
labels
attachments
/**
 * Converts a byte array to hex string
 */
public static String toHexString(byte[] block) {
    StringBuffer buf = new StringBuffer();
    char[] hexChars = { 
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 
        'A', 'B', 'C', 'D', 'E', 'F' };
    int len = block.length;
    int high = 0;
    int low = 0;
    for (int i = 0; i < len; i++) {
        high = ((block[i] & 0xf0) >> 4);
        low = (block[i] & 0x0f);
        buf.append(hexChars[high]);
        buf.append(hexChars[low]);
    } 
    return buf.toString();
}
no comments | post comment
Describe here what your SnipSnap is about!

Configure this box!

  1. Login in
  2. Click here: snipsnap-portlet-2
  3. Edit this box
www.brandonburk.com | Copyright 2008 Brandon N. Burk