Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(File file) throws IOException { BufferedReader br = new BufferedReader(new FileReader(file)); String l, line = ""; while ((l = br.readLine()) != null) line += l; br.close(); line = line.replace("\t", ""); int begin = line.indexOf("<!--"); while (begin > 0) { int end = line.indexOf("-->") + 3; if (end > begin) { line = line.replace(line.substring(begin, end), ""); begin = line.indexOf("<!--"); } else throw new RuntimeException("Comment opened but not closed!"); } return line.substring(line.indexOf('>') + 1); } }