1 /*
2  * @(#) $Id: Util.java,v 1.2 2003/07/08 08:13:52 pankaj Exp $
3  *
4  * Copyright (c) 2002-03 by Pankaj Kumar (http://www.pankaj-k.net). 
5  * All rights reserved.
6  *
7  * The license governing the use of this file can be found in the 
8  * root directory of the containing software.
9  */
10public class Util {
11    private static char[] hexChars = {
12        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
13    };
14    public static String byteArray2Hex(byte[] ba){
15        StringBuffer sb = new StringBuffer();
16        for (int i = 0; i < ba.length; i++){
17            int hbits = (ba[i] & 0x000000f0) >> 4;
18            int lbits = ba[i] & 0x0000000f;
19            sb.append("" + hexChars[hbits] + hexChars[lbits] + " ");
20        }
21        return sb.toString();
22    }
23}