public static String fromBytes(byte[] bytes) throws IOException {
    DataInputBuffer dbuf = new DataInputBuffer();
    dbuf.reset(bytes, 0, bytes.length);
    StringBuilder buf = new StringBuilder(bytes.length);
    readChars(dbuf, buf, bytes.length);
    return buf.toString();
  }
@Test
  public void testInvalidUTF8Truncated() throws Exception {
    // Truncated CAT FACE character -- this is a 4-byte sequence, but we
    // only have the first three bytes.
    byte[] truncated = new byte[] {
        (byte)0xF0, (byte)0x9F, (byte)0x90 };
    try {
      UTF8.fromBytes(truncated);
      fail("did not throw an exception");
    } catch (UTFDataFormatException utfde) {
      GenericTestUtils.assertExceptionContains(
          "Truncated UTF8 at f09f90", utfde);
    }
  }