@Test
void test() throws IOException {

    final StringBuilder sb = new StringBuilder();
    for (int line = 1; line <= 100; line++) {
        sb.append("line");
        sb.append(line);
        for (int col = 1; col <= 100; col++) {
            sb.append(",col");
            sb.append(col);
        }
        sb.append("\n");
    }
    final String input = sb.toString();
    final ByteArrayInputStream inputStream = new ByteArrayInputStream(input.getBytes(StreamUtil.DEFAULT_CHARSET));
    final PreviewInputStream previewInputStream = new PreviewInputStream(inputStream);
    String data = previewInputStream.previewAsString(200, StreamUtil.DEFAULT_CHARSET_NAME);
    System.out.println(data);
    assertThat(input.startsWith(data)).isTrue();
    data = previewInputStream.previewAsString(200, StreamUtil.DEFAULT_CHARSET_NAME);
    System.out.println(data);
    assertThat(input.startsWith(data)).isTrue();
    data = previewInputStream.previewAsString(200, StreamUtil.DEFAULT_CHARSET_NAME);
    System.out.println(data);
    assertThat(input.startsWith(data)).isTrue();
    final String output = StreamUtil.streamToString(previewInputStream, true);
    assertThat(output).isEqualTo(input);
}