title: How to apply regex to entire file, not just line after line?
body: <p>I want to apply my regular expression not just to the first line of the text file, but to the all lines together. 
  Currently it matches only when the entire appropriate match is on one line. And if the appropriate match continues on the next line - it doesn't match at all.</p>
  
  <pre><code> class Parser {
    public static void main(String[] args) throws IOException {
  
      Pattern patt = Pattern.compile("(include|"
              + "integrate|"
              + "driven based on|"
              + "facilitate through|"
              + "contain|"
              + "using|"
              + "equipped"
              + "integrate|"
              + "implement|"
              + "utilized to facilitate|"
              + "comprise){1}"
              + "[\\s\\w\\,\\(\\)\\;\\:]*\\.");  //Regex
      BufferedReader r = new BufferedReader(new FileReader("E:/test/test.txt")); // read the file
  
  
      String line;
      PrintWriter pWriter = null; 
      while ((line = r.readLine()) != null) {           
        Matcher matcher = patt.matcher(line);  
       while (matcher.find()) { 
  
           try{
               pWriter = new PrintWriter(new BufferedWriter(new FileWriter("E:/test/test1.txt", true)));//append any given input 
               pWriter.println(matcher.group());  //write the result of matcher to the new file
           } catch (IOException ioe) { 
               ioe.printStackTrace(); 
           } finally { 
               if (pWriter != null){ 
                   pWriter.flush(); 
  
                   pWriter.close(); 
               } 
           }
  
          System.out.println(matcher.group());   
  
        }
      }
    }
  }
  </code></pre>