/** * Write a printable representation of a byte array. * * @param b byte array * @return string * @see #toStringBinary(byte[], int, int) */ public static String toStringBinary(final byte [] b) { if (b == null) return "null"; return toStringBinary(b, 0, b.length); }
/** * Write a printable representation of a byte array. * * @param b byte array * @return string * @see #toStringBinary(byte[], int, int) */ public static String toStringBinary(final byte [] b) { if (b == null) return "null"; return toStringBinary(b, 0, b.length); }
/** * Converts the given byte buffer to a printable representation, * from the index 0 (inclusive) to the limit (exclusive), * regardless of the current position. * The position and the other index parameters are not changed. * * @param buf a byte buffer * @return a string representation of the buffer's binary contents * @see #toBytes(ByteBuffer) * @see #getBytes(ByteBuffer) */ public static String toStringBinary(ByteBuffer buf) { if (buf == null) return "null"; if (buf.hasArray()) { return toStringBinary(buf.array(), buf.arrayOffset(), buf.limit()); } return toStringBinary(toBytes(buf)); }
/** * Converts the given byte buffer to a printable representation, * from the index 0 (inclusive) to the limit (exclusive), * regardless of the current position. * The position and the other index parameters are not changed. * * @param buf a byte buffer * @return a string representation of the buffer's binary contents * @see #toBytes(ByteBuffer) * @see #getBytes(ByteBuffer) */ public static String toStringBinary(ByteBuffer buf) { if (buf == null) return "null"; if (buf.hasArray()) { return toStringBinary(buf.array(), buf.arrayOffset(), buf.limit()); } return toStringBinary(toBytes(buf)); }
/** * Writes a string as a fixed-size field, padded with zeros. */ public static void writeStringFixedSize(final DataOutput out, String s, int size) throws IOException { byte[] b = toBytes(s); if (b.length > size) { throw new IOException("Trying to write " + b.length + " bytes (" + toStringBinary(b) + ") into a field of length " + size); } out.writeBytes(s); for (int i = 0; i < size - s.length(); ++i) out.writeByte(0); }
/** * Writes a string as a fixed-size field, padded with zeros. */ public static void writeStringFixedSize(final DataOutput out, String s, int size) throws IOException { byte[] b = toBytes(s); if (b.length > size) { throw new IOException("Trying to write " + b.length + " bytes (" + toStringBinary(b) + ") into a field of length " + size); } out.writeBytes(s); for (int i = 0; i < size - s.length(); ++i) out.writeByte(0); }
HRegionLocation location = htable.getRegionLocation(tableRange.getFirst()[i], false); if (location == null) { throw new IOException("Can't find the region of the key: " + Bytes.toStringBinary(tableRange.getFirst()[i]));
HRegionLocation location = htable.getRegionLocation(tableRange.getFirst()[i], false); if (location == null) { throw new IOException("Can't find the region of the key: " + Bytes.toStringBinary(tableRange.getFirst()[i]));