### Question:
StringUtils { public static String getPreview(String text, int linesCount, boolean ignoreEmptyLines, Integer maxLength) { if (maxLength != null && maxLength < 0) { throw new IllegalArgumentException("maxLength can't be negative"); } if (text == null) { return "<null>"; } if (text.isEmpty() || linesCount <= 0) { return ""; } Scanner scanner = new Scanner(text); return getPreview(linesCount, ignoreEmptyLines, maxLength, scanner); } private  StringUtils(); static String getPreview(String text, int linesCount, boolean ignoreEmptyLines, Integer maxLength); static String getPreview(InputStream is, String encoding, int linesCount, boolean ignoreEmptyLines,
                                    Integer maxLength);  }### Answer:
@Test public void test() throws IOException { String text = getResourceText("Script.groovy"); String preview = StringUtils.getPreview(text, 2, true, Integer.MAX_VALUE); assertEquals("package com.icthh.xm.lep.script\\n\\ndef description = \"'Logic Extension Point 2017'\"", preview); preview = StringUtils.getPreview(text, 2, false, Integer.MAX_VALUE); assertEquals("package com.icthh.xm.lep.script\\n", preview); }