title: How to get the number of lines from a text file in java ignoring blank lines?
body: <p>At the moment to count the number of lines from a text file I'm using :</p>
  
  <pre><code>File f = new File("lorem.txt");
  if(f.exists()){
          try {
              BufferedReader bf = new BufferedReader(new FileReader(f));
  
              while((s = bf.readLine())!=null) {
                  if(s.length() &gt; 0) {
                      nbLinesTotal++;
                  }
              }
              bf.close();
          }
          catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }       
  }
  </code></pre>
  
  <p>But I discovered this in java 8 : </p>
  
  <pre><code>long count = Files.lines(Paths.get("lorem.txt")).count();
  </code></pre>
  
  <p>which is way faster and better than my loop. But it doesn't ignore blank lines. So, How can I ignore blank lines with this way to do ?</p>
  
  <p>Thanks</p>