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

ca.uhn.hl7v2.hoh.util.ByteUtils Maven / Gradle / Ivy

There is a newer version: 2.5.1
Show newest version
package ca.uhn.hl7v2.hoh.util;

public class ByteUtils {

	// non instantiable
	private ByteUtils() {}
	
	/**
	 * Formats a byte array for logging
	 */
	public static String formatBytesForLogging(int numBytes, int theOffset, byte... theBytes) {
		StringBuilder b = new StringBuilder();
		int end = numBytes + theOffset;
		for (int i = theOffset; i < end; i++) {
			byte nextByte = theBytes[i];
			if (nextByte < ' ' || nextByte > 126) {
				b.append('[');
				b.append((int) nextByte);
				b.append(']');
			} else {
				b.append((char) nextByte);
			}
		}

		return (b.toString());
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy