/** * Display the content, i.e. bits, of a byte array. Write to stdout the content of the array on a * single line. </br> Code taken from Lucene-1410. * * @param array The byte array */ public static void writeBytes(final byte[] array) { final StringBuffer buf = new StringBuffer(); for (final byte element : array) { CodecUtils.writeBits(element & 255, buf); buf.append(' '); } System.out.println(buf); }
/** * Display the content, i.e. bits, of a byte array. Write to stdout 4 bytes per lines. </br> Code * taken from Lucene-1410. * * @param array The byte array */ public static void writeIndentBytes(final byte[] array) { final StringBuffer buf = new StringBuffer(); for (int i = 0; i < array.length; i++) { CodecUtils.writeBits(array[i] & 255, buf); if (((i + 1) % 4) != 0) { buf.append(' '); } else { System.out.println(buf); buf.setLength(0); } } }