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

org.opentripplanner.framework.text.HexString Maven / Gradle / Ivy

The newest version!
package org.opentripplanner.framework.text;

/**
 * Converts a byte array to its hexadecimal representation
 */
public class HexString {

  private static final char[] HEX_CHARS = "0123456789abcdef".toCharArray();

  private HexString() {}

  public static String of(byte[] data) {
    // two characters form the hex value.
    StringBuilder out = new StringBuilder(data.length * 2);
    for (byte b : data) {
      out.append(HEX_CHARS[(0xF0 & b) >>> 4]);
      out.append(HEX_CHARS[0x0F & b]);
    }
    return out.toString();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy