@Test public void testFindLinesContaining() { String text = "LiXXXne 1\nLine 2\n\nLXXXine 4\r\nLine 5\r\nXXX\r\nLine 7"; List<String> lines = StringUtils.findLinesContaining(text, "XXX"); assertEquals(3, lines.size()); assertEquals("LiXXXne 1", lines.get(0)); assertEquals("LXXXine 4", lines.get(1)); assertEquals("XXX", lines.get(2)); }
public static List<String> findLinesContaining(String text, String searchText) { String[] splitLinesSkipEmpty = splitLines(text, true); List<String> matching = new ArrayList<>(); for (String line : splitLinesSkipEmpty) { if (line.contains(searchText)) { matching.add(line); } } return matching; }
StringUtils { public static List<String> findLinesContaining(String text, String searchText) { String[] splitLinesSkipEmpty = splitLines(text, true); List<String> matching = new ArrayList<>(); for (String line : splitLinesSkipEmpty) { if (line.contains(searchText)) { matching.add(line); } } return matching; } }
StringUtils { public static List<String> findLinesContaining(String text, String searchText) { String[] splitLinesSkipEmpty = splitLines(text, true); List<String> matching = new ArrayList<>(); for (String line : splitLinesSkipEmpty) { if (line.contains(searchText)) { matching.add(line); } } return matching; }  }
StringUtils { public static List<String> findLinesContaining(String text, String searchText) { String[] splitLinesSkipEmpty = splitLines(text, true); List<String> matching = new ArrayList<>(); for (String line : splitLinesSkipEmpty) { if (line.contains(searchText)) { matching.add(line); } } return matching; }  static String[] split(String string, char delimiter); static String encodeUrl(String stringToEncode); static String encodeUrlIso(String stringToEncode); static String decodeUrl(String stringToDecode); static String decodeUrlIso(String stringToDecode); static String md5(String stringToEncode); static String sha1(String stringToEncode); static String digest(String string, String digestAlgo, String encoding); static String hex(byte[] bytes); static byte[] parseHex(String hex); static int parseHexDigit(char c); static String resolveEntity(String entity); static String ellipsize(String text, int maxLength); static String ellipsize(String text, int maxLength, String end); static String[] splitLines(String text, boolean skipEmptyLines); static List<String> findLinesContaining(String text, String searchText); static String join(Iterable<?> iterable, String separator); static String join(int[] array, String separator); static String join(String[] array, String separator); }
StringUtils { public static List<String> findLinesContaining(String text, String searchText) { String[] splitLinesSkipEmpty = splitLines(text, true); List<String> matching = new ArrayList<>(); for (String line : splitLinesSkipEmpty) { if (line.contains(searchText)) { matching.add(line); } } return matching; }  static String[] split(String string, char delimiter); static String encodeUrl(String stringToEncode); static String encodeUrlIso(String stringToEncode); static String decodeUrl(String stringToDecode); static String decodeUrlIso(String stringToDecode); static String md5(String stringToEncode); static String sha1(String stringToEncode); static String digest(String string, String digestAlgo, String encoding); static String hex(byte[] bytes); static byte[] parseHex(String hex); static int parseHexDigit(char c); static String resolveEntity(String entity); static String ellipsize(String text, int maxLength); static String ellipsize(String text, int maxLength, String end); static String[] splitLines(String text, boolean skipEmptyLines); static List<String> findLinesContaining(String text, String searchText); static String join(Iterable<?> iterable, String separator); static String join(int[] array, String separator); static String join(String[] array, String separator);  }