public static String arrayToNewlines(Object[] array, int maxLine) {
    int n = (maxLine > 0 && array.length > maxLine) ? maxLine : array.length;
    StringBuilder b = new StringBuilder();
    for (int i = 0; i < n; i++) {
      b.append(array[i]);
      b.append("\n");
    }
    if (array.length > maxLine) {
      b.append("...\n");
    }
    return b.toString();
  }
@Test
  public void testArrayToNewlines() {
    Object[] uuids = IntStream.range(1, 10).mapToObj(unused -> UUID.randomUUID()).toArray();

    String r1 = StringUtils.arrayToNewlines(uuids, 6);
    assertTrue(r1.endsWith("...\n"));
    assertEquals(7, countMatches(r1, "\n"));
    String r2 = StringUtils.arrayToNewlines(uuids, 15);
    String r3 = StringUtils.arrayToNewlines(uuids, 10);
    assertEquals(r3, r2);
  }