title: How to check if file content is empty
body: <p>I am trying to check if a file content is empty or not. I have a source file where the content is empty.
  I tried different alternatives.But nothing is working for me.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>  Path in = new Path(source);
      /*
       * Check if source is empty
       */
      BufferedReader br = null;
      try {
          br = new BufferedReader(new InputStreamReader(fs.open(in)));
      } catch (IOException e) {
          e.printStackTrace();
      }
      try {
          if (br.readLine().length() == 0) {
              /*
               * Empty file
               */
              System.out.println("In empty");
              System.exit(0);
  
          }
          else{
              System.out.println("not empty");
          }
      } catch (IOException e) {
          e.printStackTrace();
  
      }
  </code></pre>
  
  <p>I have tried using - </p>
  
  <pre><code>1. br.readLine().length() == 0
  2. br.readLine() == null
  3. br.readLine().isEmpty()
  </code></pre>
  
  <p>All of the above is giving as not empty.And I need to use -</p>
  
  <pre><code>BufferedReader br = null;
          try {
              br = new BufferedReader(new InputStreamReader(fs.open(in)));
          } catch (IOException e) {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>Instead of new File() etc.</p>
  
  <p>Please advice if I went wrong somewhere.</p>
  
  <p>EDIT</p>
  
  <blockquote>
    <p>Making little more clear. If I have a file with just whitespaces or
    without white space,I am expecting my result as empty.</p>
  </blockquote>