arrays - Matching words in a list against a stringarray in java -


i need find , replace list of words given user. application reads line line in html file , want verify if there word list , replace blank space. have until think have modify hole code in order want.

    private static void printfile(file source) throws ioexception {     string s;     filereader fr = new filereader(source);     @suppresswarnings("resource")     bufferedreader br = new bufferedreader(fr);      @suppresswarnings("resource")     printwriter pw = new printwriter("results.txt");     while ((s=br.readline())!=null) {         pw.println(s.replaceall("&#160;", "") //words replaced.                 .replaceall("<br>", "")                 .replaceall("&amp;", "")                 .replaceall("</p>", "")                 .replaceall("</body>","")                 .replaceall("</html>", "")                 .replaceall("<remote object=\"#default\">&gt;", ""));     }     system.out.println("done!"); } 

i accept suggestions, list idea may not best option.

you can remove html markup simple jsoup:

public static string html2text(string html) {   return jsoup.parse(html).text(); } 

also have @ cleaner , whitelist sanatize documents individually.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -