### Question:
Utf8StringUtils { public static List<String> utf8byteSizeSplit(String s, int maxChunkBytes) { if (maxChunkBytes < 6) { throw new IllegalArgumentException("Max UTF-8 chunk size cannot be less than 6"); } byte[] bytes = s.getBytes(UTF8); List<String> result = new ArrayList<String>(); int chunkStartOffset = 0; int chunkLength = 0; for (byte b : bytes) { if (chunkLength + utf8CharBytes(b) > maxChunkBytes) { result.add(new String(bytes, chunkStartOffset, chunkLength, UTF8)); chunkStartOffset += chunkLength; chunkLength = 0; } chunkLength++; } if (chunkLength > 0) { result.add(new String(bytes, chunkStartOffset, chunkLength, UTF8)); } return result; } private  Utf8StringUtils(); static List<String> utf8byteSizeSplit(String s, int maxChunkBytes); static int utf8CharBytes(byte b); static int oneBitCount(byte b);  }### Answer:
@Test public void testUtf8byteSizeSplit() { int runs = 10 + random.nextInt(10); System.out.println("Running " + runs + " random UTF-8 string-split tests..."); for (int r=0; r<runs; r++) { String source = RandomStringUtils.random(100000); int size = 6 + random.nextInt(1000); List<String> splitList = Utf8StringUtils.utf8byteSizeSplit(source, size); StringBuilder stiched = new StringBuilder(); for (String chunk : splitList) { stiched.append(chunk); } assertEquals(source, stiched.toString()); } }