blob: 96f87432a4fb96e2beefaaef054cd33a4ecc1f1f [file] [log] [blame]
package net.onrc.onos.datastore.utils;
import java.nio.ByteBuffer;
public class ByteArrayUtil {
public static StringBuffer toHexStringBuffer(final byte[] bytes,
final String sep) {
return toHexStringBuffer(bytes, sep, new StringBuffer());
}
public static StringBuffer toHexStringBuffer(final byte[] bytes,
final String sep, StringBuffer buf) {
if (bytes == null) {
return buf;
}
ByteBuffer wrap = ByteBuffer.wrap(bytes);
boolean hasWritten = false;
while (wrap.hasRemaining()) {
if (hasWritten) {
buf.append(sep);
}
buf.append(Integer.toHexString(wrap.get()));
hasWritten = true;
}
return buf;
}
}