title: How to continue execution after a throw exception in Java?
body: <p>I am reading HTML files from a folder using xml parser that store the clean code in tagNode </p>
  
  <pre><code>try {
      Document doc = new DomSerializer(props, true).createDOM(tagNode);
  } catch (Exception ex) {
   ex.printStackTrace();
  }
  </code></pre>
  
  <p>But one of the files is giving me an error :</p>
  
  <pre><code>org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. 
  </code></pre>
  
  <p>How I can continue running the program after the exception is caught ?</p>
  
  <hr>
  
  <p>solution #1</p>
  
  <pre><code>    try 
      {
              File folder = new File(path);
              File[] listOfFiles = folder.listFiles();
          FileWriter fstream = new FileWriter("dataset.txt");
              BufferedWriter br= new BufferedWriter(fstream);
  
  
  for (int i = 0; i &lt; listOfFiles.length; i++) {    
  {
          try {
              Document doc = new DomSerializer(props, true).createDOM(tagNode);
          } catch (Exception ex) {
           ex.printStackTrace();
          }
      }
      } catch (Exception ex) {
           ex.printStackTrace();
          }
  </code></pre>
  
  <hr>
  
  <p>Given a way around it , why I am getting this error ?  </p>