title: Can anyone tell me why the java code does not go into the if statement
body: <p>Hi guys I have written a code which will output the contents from a xml files located in different folders into a csv file. But when there are no xml files, I would like to return a print statement with "No files" found.</p>
  
  <p>The issue is my code just refuses to go into the main if statement and always executes the else statement.</p>
  
  <p>Below is my code.</p>
  
  <pre><code>public class XMLReadExtract {
  
      public void extract_XML_Data(String InputPath, File OutputPath, FileWriter fileWriter) throws Exception {
  
          String COMMA_DELIMITER = ",";                                                   /* Delimiter used for csv */
  
          File root = new File(InputPath);
          File[] list = root.listFiles();                                                 /* To List all files in the Input Path */
  
  
          try{        
              if (list == null){
                  System.out.println("No files to be read");
                  return;
              }                                                                               // End of main If Statement
  </code></pre>