title: How to download file from FTP using Java?
body: <p>With this code iI always get a empty file.<br>
  What I have to do with it?<br>
  <code>login</code> is always <code>true</code>. (ofc, here is not real password)<br></p>
  
  <pre><code>import org.apache.commons.net.ftp.FTPClient;
  import org.apache.commons.net.ftp.FTPFile;
  
  import java.io.*;
  
  public class Logs {
      public static void main(String[] args) {
          FTPClient client = new FTPClient();
  
          try {
              client.connect("myac.cs-server.pro", 121);
              boolean login = client.login("a3ro", "passWordIsSecret");
              System.out.println(login);
              String remoteFile1 = "myac_20150304.log";
              File downloadFile1 = new File("C:\\Users\\Aero\\Desktop\\test\\myac.log");
              OutputStream outputStream1 =
                  new BufferedOutputStream(new FileOutputStream(downloadFile1));
              boolean success = client.retrieveFile(remoteFile1, outputStream1);
              System.out.println(success);
              outputStream1.close();
          } catch (IOException e) {
              e.printStackTrace();
          } finally {
              try {
                  client.disconnect();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
  }
  </code></pre>