title: checking if file exists in a specific directory
body: <p>I am trying to check for a specific file in a given directory. I don't want the code but I want to fix the one I have. The only difference in this question, is that I look for files with an extension <code>.MOD</code>.</p>
  
  <p>I have the code ready:-</p>
  
  <pre><code>public static int checkExists(String directory, String file) {
      File dir = new File(directory);
      File[] dir_contents = dir.listFiles();
      String temp = file + ".MOD";
      boolean check = new File(temp).exists();
      System.out.println("Check"+check);  // --&gt;always says false
  
      for(int i = 0; i&lt;dir_contents.length;i++) {
          if(dir_contents[i].getName() == (file + ".MOD"))
              return Constants.FILE_EXISTS;
      }
  
      return Constants.FILE_DOES_NOT_EXIST;
  }
  </code></pre>
  
  <p>But for some reasons, it does not work. I don't understand why, can anybody find any bug here?</p>