title: Download file using FTP on Android
body: <p>This is my class has download files from ftp</p>
  
  <pre><code>public void run() {
  
      FTPClient ftpClient = new FTPClient();
      try {
  
          ftpClient.connect(server, port);
          ftpClient.login(user, pass);
          ftpClient.enterLocalPassiveMode();
          ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
          String remoteFile1 = "/WhiteList.txt";
          File downloadFile1 = new File("/data/data/com.prosec/files/WhiteList.txt");
  
          OutputStream outputStream1 = new BufferedOutputStream(new FileOutputStream(downloadFile1));
  
          boolean success = ftpClient.retrieveFile(remoteFile1, outputStream1);
          outputStream1.close();
  </code></pre>
  
  <p>In my MainAcitivy, I instance the ftp class when I open my app (OnCreate()).</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      btn = (Button) findViewById(R.id.btn);
      btnDicas = (Button) findViewById(R.id.btnDicas);
      out = (TextView) findViewById(R.id.out);
      listView = (ListView) findViewById(R.id.list);
      new Thread(new ReceiveFTP()).start();// HERE
  </code></pre>
  
  <p>I'm problems in this line</p>
  
  <pre><code>OutputStream outputStream1 = new BufferedOutputStream(new FileOutputStream(downloadFile1));
  </code></pre>
  
  <p>The log:</p>
  
  <pre><code>03-12 09:06:37.704 7457-7509/? I/System.out: Error: /data/data/com.prosec/files/WhiteList.txt: open failed: ENOENT (No such file or directory)
  03-12 09:06:37.704 7457-7509/? W/System.err: java.io.FileNotFoundException: /data/data/com.prosec/files/WhiteList.txt: open failed: ENOENT (No such file or directory)
  03-12 09:06:37.704 7457-7509/? W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:456)
  03-12 09:06:37.712 7457-7509/? W/System.err:     at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:87)
  03-12 09:06:37.712 7457-7509/? W/System.err:     at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:72)
  03-12 09:06:37.712 7457-7509/? W/System.err:     at com.prosec.ReceiveFTP.run(ReceiveFTP.java:43)
  </code></pre>
  
  <p>If I closed the app, and open again, works fine. This error ocurred only first time </p>