title: Java File exists Case sensitive .jpg and .JPG
body: <p>I use this function to detect if my file exists or not. While I have some image stored as .jpg, .JPG, .png, and .PNG. But it always return .jpg or .png as true even if the real file has extension .JPG or .PNG.</p>
  
  <p>After I render it to my webpage it throws an error "Failed to load resource: the server responded with a status of 404 (Not Found)".</p>
  
  <pre><code>public static String getPhotoFileExtension(int empKey){
      try{
          String[] types = {".jpg",".JPG",".png", ".PNG"};
          for(String t : types)
          {
              String path = "/"+Common.PHOTO_PATH + empKey + t;
              File f = new File(Sessions.getCurrent().getWebApp()
                      .getRealPath(path));
              if(f.isFile()) 
                  return t;
          }
      }catch (Exception e) {
          e.printStackTrace();
      }
      return "";
  }
  </code></pre>