File:  [Public] / java / classes / org / w3c / util / StringUtils.java
Revision 1.4: download - view: text, annotated - select for diffs
Tue Jun 26 09:47:28 2012 UTC (13 years, 2 months ago) by ylafon
Branches: MAIN
CVS tags: HEAD
more cleanup + use of HashMap and ConcurrentHashMap in the resource store

// StringUtils.java
// $Id: StringUtils.java,v 1.4 2012/06/26 09:47:28 ylafon Exp $
// (c) COPYRIGHT MIT, INRIA and Keio, 1999.
// Please first read the full copyright statement in file COPYRIGHT.html

package org.w3c.util;

public class StringUtils {
    /**
     * to hex converter
     */
    private static final char[] toHex = {
            '0', '1', '2', '3',
            '4', '5', '6', '7',
            '8', '9', 'a', 'b',
            'c', 'd', 'e', 'f'};

    /**
     * convert an array of bytes to an hexadecimal string
     *
     * @param b an array of bytes
     * @return a string
     */

    public static String toHexString(byte b[]) {
        int pos = 0;
        char[] c = new char[b.length * 2];
        for (byte bi : b) {
            c[pos++] = toHex[(bi >> 4) & 0x0F];
            c[pos++] = toHex[bi & 0x0f];
        }
        return new String(c);
    }
}

Webmaster