StringTools { public static String getMetaDataFromHTML(String html) { Document doc = Jsoup.parse(html); return doc.head().html(); }  static int getLevenshteinDistance(String str1, String str2); static Set<String> getApproximatelyMatchingStringList(String sourceString, String search); boolean isNotTooShort(String string); static Set<String> getApproximatelyMatchingStringList(String sourceString, String search, int maxDistance); static String getCompletingString(String string, int begin, int end); static List<MatchingWindow> getMatchingWindowsAboveThreshold(String text, String search, double threshold); static Set<String> splitIntoWordsWithLengthHigherThan(String string, int minLength); static Set<String> splitIntoWordsWithLengthHigherThan(String string, int minLength, String... ignoreWords); static boolean noContentInHtml(String text); static List<String> getRegexMatchesWithMinLength(String text, String regex, int minLength); static String getRandomForeName(); static String getRandomSurname(); static String getFirstHtmlWithContent(String html); static String getMetaDataFromHTML(String html); static String addMetaDataToHtml(String htmlText, String metaData);  }
@Test public void shouldGetMetaDataFromHTML() { String html = "<html xmlns=\"http: "<head>\n" + "<meta name=\"X-Parsed-By\" content=\"org.apache.tika.parser.DefaultParser\" />\n" + "<meta name=\"X-Parsed-By\" content=\"org.apache.tika.parser.ocr.TesseractOCRParser\" />\n" + "<meta name=\"Content-Type\" content=\"image/tiff\" />\n" + "<title></title>\n" + "</head>\n" + "<body><div>Replace this ﬁle with prentcsmacro . sty for your meeting,\n" + "or with entcsinacro.st for your meeting. Both can be\n" + "found at the LN l‘CS l\\= acro Home Page.\n" + "\n" + "An Example Paper\n" + "</div>\n" + "</body></html>"; String result = StringTools.getMetaDataFromHTML(html); assertThat(result, equalTo("<meta name=\"X-Parsed-By\" content=\"org.apache.tika.parser.DefaultParser\"> \n<meta name=\"X-Parsed-By\" content=\"org.apache.tika.parser.ocr.TesseractOCRParser\"> \n<meta name=\"Content-Type\" content=\"image/tiff\"> \n<title></title>")); }