All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.httpcache4j.util.Hex Maven / Gradle / Ivy

The newest version!
package org.codehaus.httpcache4j.util;

/**
 * @author Erlend Hamnaberg
 */
public class Hex {

    public static String encode(byte[] bytes) {
        // TODO(user): Use c.g.common.base.ByteArrays once it is open sourced.
        StringBuilder sb = new StringBuilder(2 * bytes.length);
        for (byte b : bytes) {
            sb.append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]);
        }
        return sb.toString();
    }
    private static final char[] hexDigits = "0123456789abcdef".toCharArray();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy