Untitled
unknown
java
a year ago
1.5 kB
2
Indexable
Never
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; public class App { public static String readHTML() { StringBuilder contentBuilder = new StringBuilder(); try { //take input BufferedReader in = new BufferedReader(new FileReader("./src/den.html")); String str; while ((str = in.readLine()) != null) { //append to the string builder contentBuilder.append(str); } in.close(); String content = contentBuilder.toString(); content = content.toUpperCase(); //find the body Pattern pattern = Pattern.compile("<BODY.*?>(.*?)</BODY>"); Matcher matcher = pattern.matcher(content); if (matcher.find()) { String body = matcher.group(1); return body; } return null; } catch (IOException e) { System.out.println(e); return null; } } public static void main(String[] args) throws Exception { String input = readHTML(); // find the run time of the program // long start = System.currentTimeMillis(); // long end = System.currentTimeMillis(); // System.out.println("Time: " + (end - start) + "ms"); } }