title: Reading null values from BufferedReader in command prompt input
body: <p>I'm trying to read from the user's input from command line. For the input for <code>filename</code>, the program is supposed to exit whenever it detects that the user has submitted a blank value.</p>
  
  <p>However, the program is always going to the "Inside Reading file" code, regardless of whether the user input contains anything or not. It never gets to execute the "Program will exit now" code. I've tried different ways of coding it, and all of them came back with the same results. Is there anything wrong with it?</p>
  
  <pre><code>public static void main(String[] args) throws Exception {
  
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String collection; 
      String filename;
  
      System.out.println("Enter the collection name: ");
      collection = br.readLine();
  
      String urlString = "http://localhost:8983/solr/" + collection;
      solr = new HttpSolrClient(urlString);
  
      doc1 = new SolrInputDocument ();
  
      while (true){
  
          System.out.println("Enter the file name: ");
          while ((filename = br.readLine()) !=null) {
              System.out.println("Inside reading file ");
              parseUsingStringTokenizer(filename);
              System.out.println("Enter the file name: ");
          }
          System.out.println("Program will exit now...");
          System.exit(0);
  
      }
  }
  </code></pre>