title: how can I get the previous line by reading file line by line
body: <p>I am reading a file line by line using Scanner. So my question is how can I also store the previous line side by side as we keep on moving to next line.    </p>
  
  <pre><code>    while (scanner.hasNextLine()) {
      line = scanner.nextLine();//this will get the current line
      if (line.contains("path=/select")){
      // So whenever I enter in this if loop or this loop is true, I also want to 
      have the  previous line in any String variable. How can we achieve this?
       }
  </code></pre>
  
  <p>Any suggestions will be appreciated.</p>