### Question:
CharsetUtil { public static byte[] getUtf8Bytes(String s) { if (s == null) { return ArrayUtils.EMPTY_BYTE_ARRAY; } ByteBuffer bb = Charsets.UTF_8.encode(s); return ArrayUtils.subarray(bb.array(), 0, bb.limit()); } private  CharsetUtil(); static byte[] getUtf8Bytes(String s); static String newUtf8String(byte[] b);  }### Answer:
@Test public void testGetUtf8String() { ArrayAssert.assertEquals(new byte[] { 0x69, 0x6e }, CharsetUtil.getUtf8Bytes("in")); ArrayAssert.assertEquals(ArrayUtils.EMPTY_BYTE_ARRAY, CharsetUtil.getUtf8Bytes(null)); testStringOfLength(0); testStringOfLength(10); testStringOfLength(100); testStringOfLength(1000); }
@Test public void testLatin1() { ArrayAssert.assertEquals(LATIN1_UTF8_DATA, CharsetUtil.getUtf8Bytes(LATIN1_STRING)); }