/** * @param b Presumed UTF-8 encoded byte array. * @return String made from <code>b</code> */ public static String toString(final byte [] b) { if (b == null) { return null; } return toString(b, 0, b.length); }
/** * Joins two byte arrays together using a separator. * @param b1 The first byte array. * @param sep The separator to use. * @param b2 The second byte array. */ public static String toString(final byte [] b1, String sep, final byte [] b2) { return toString(b1, 0, b1.length) + sep + toString(b2, 0, b2.length); }
/** * @param b Presumed UTF-8 encoded byte array. * @return String made from <code>b</code> */ public static String toString(final byte [] b) { if (b == null) { return null; } return toString(b, 0, b.length); }
/** * Joins two byte arrays together using a separator. * @param b1 The first byte array. * @param sep The separator to use. * @param b2 The second byte array. */ public static String toString(final byte [] b1, String sep, final byte [] b2) { return toString(b1, 0, b1.length) + sep + toString(b2, 0, b2.length); }
/** * Reads a fixed-size field and interprets it as a string padded with zeros. */ public static String readStringFixedSize(final DataInput in, int size) throws IOException { byte[] b = new byte[size]; in.readFully(b); int n = b.length; while (n > 0 && b[n - 1] == 0) --n; return toString(b, 0, n); }
/** * Reads a fixed-size field and interprets it as a string padded with zeros. */ public static String readStringFixedSize(final DataInput in, int size) throws IOException { byte[] b = new byte[size]; in.readFully(b); int n = b.length; while (n > 0 && b[n - 1] == 0) --n; return toString(b, 0, n); }