Annotation of java/classes/org/w3c/util/StringUtils.java, revision 1.3
1.1 ylafon 1: // StringUtils.java
1.3 ! ylafon 2: // $Id: StringUtils.java,v 1.2 2000/08/16 21:37:58 ylafon Exp $
1.1 ylafon 3: // (c) COPYRIGHT MIT, INRIA and Keio, 1999.
4: // Please first read the full copyright statement in file COPYRIGHT.html
5:
6: package org.w3c.util;
7:
8: public class StringUtils {
9: /**
10: * to hex converter
11: */
12: private static final char[] toHex = { '0', '1', '2', '3', '4', '5', '6',
13: '7', '8', '9', 'a', 'b', 'c', 'd',
14: 'e', 'f' };
1.2 ylafon 15:
1.1 ylafon 16: /**
17: * convert an array of bytes to an hexadecimal string
1.3 ! ylafon 18: * @param b an array of bytes
1.1 ylafon 19: * @return a string
20: */
21:
22: public static String toHexString(byte b[]) {
23: int pos = 0;
24: char[] c = new char[b.length*2];
25: for (int i=0; i< b.length; i++) {
26: c[pos++] = toHex[(b[i] >> 4) & 0x0F];
27: c[pos++] = toHex[b[i] & 0x0f];
28: }
29: return new String(c);
30: }
31: }
Webmaster