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

software.amazon.kinesis.producer.BinaryToHexConverter Maven / Gradle / Ivy

Go to download

The Amazon Kinesis Producer Library for Java enables developers to easily and reliably put data into Amazon Kinesis.

The newest version!
package software.amazon.kinesis.producer;

public class BinaryToHexConverter {

	private static final BinaryToHexConverter INSTANCE = new BinaryToHexConverter();
	private static final char[] HEX_CODE = "0123456789ABCDEF".toCharArray();

	/**
	 * Converts an array of bytes into a hex string.
	 *
	 * @param data An array of bytes
	 * @return A string containing a lexical representation of xsd:hexBinary
	 * @throws IllegalArgumentException if {@code data} is null.
	 */
	public static String convert(byte[] data) {
		return INSTANCE.convertToHex(data);
	}

	private String convertToHex(byte[] data) {
		StringBuilder r = new StringBuilder(data.length * 2);
		for (byte b : data) {
			r.append(HEX_CODE[(b >> 4) & 0xF]);
			r.append(HEX_CODE[(b & 0xF)]);
		}
		return r.toString();
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy