title: How to check if file exist when downloading from FTP
body: <p>I'm downloading from FTP server and I don't know exactly how to check if file already exist. What I want to do is that I retrieve filname from FTP server and then compare it with all files in folder. If file already exists then it compares next FTP filename with all files in folder and so on. 
  I already did comparison and it's working if all files from folder have same name as files on FTP server but if I add some older file then it downloads all files once again and I don't want that. </p>
  
  <p>Here is my scratch code:</p>
  
  <pre><code>String[] names = client.listNames();
          File folder = new File("c:\\test\\RTR_ZIP\\");
          String[] filename = folder.list();
  
          for (;i&lt;names.length;i++) {
              name = names[i];
  
              exists=false;
  
                  if (name.contains(".zip")) {
  
                      if (filename.length == 0) {
                          new_file = new FileOutputStream("C:\\test\\RTR_ZIP\\" + name);
                          client.retrieveFile(name, new_file);
                          j++;
                          exists=true;
                      } else {
                              for (;k&lt;filename.length;k++) {
                              name = names[i];
                              i++;
                              name1=filename[k];
      //                        CHECK IF FILE EXISTS
                                      if (!name.equals(name1)) {
                                          new_file = new FileOutputStream("C:\\test\\RTR_ZIP\\" + name);
                                          client.retrieveFile(name, new_file);
                                          j++;
                                          exists=true;
                                      } 
                              }
                        }//else
                  }//if contains .zip
          }//for
  </code></pre>
  
  <p>Thanks in advance. </p>