title: Ftp File download From java code
body: <p>i have this code to download a single file .</p>
  
  <pre><code>    import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.OutputStream;
  import org.apache.commons.net.ftp.FTPClient;
  public class NetTest {
  public static void main(String[] args){
  FTPClient client = new FTPClient( );
  OutputStream outStream;
      try {
  </code></pre>
  
  <p>this is the part of server and passwords .</p>
  
  <pre><code>   client.connect( "servername" );
      client.login("noman123", "pass");
      String remoteFile = "/a.txt";
      outStream = new FileOutputStream( "a.txt" );
  </code></pre>
  
  <p>simple fill downloading but error on this line</p>
  
  <pre><code>    client.retrieveFile( remoteFile, outStream );
  } catch(IOException ioe) {
      System.out.println( "Error communicating with FTP server." );
  } finally {
      try {
          client.disconnect( );
      } catch (IOException e) {
          System.out.println( "Problem disconnecting from FTP server" );
      }
  }
  
  }
  }
  </code></pre>
  
  <p>and it gives me errors like 
  i hope that u can understand the issue that i m facing now </p>
  
  <blockquote>
    <p>java.net.SocketException: Software caused connection abort: socket write error
            at java.net.SocketOutputStream.socketWrite0(Native Method)
            at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
            at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
            at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
            at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
            at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)
            at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
            at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
            at java.io.BufferedWriter.flush(BufferedWriter.java:254)
            at org.apache.commons.net.ftp.FTP.__send(FTP.java:496)
            at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:470)
            at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:547)
            at org.apache.commons.net.ftp.FTP.port(FTP.java:872)
            at org.apache.commons.net.ftp.FTPClient.<em>openDataConnection</em>(FTPClient.java:667)
            at org.apache.commons.net.ftp.FTPClient.retrieveFile(FTPClient.java:1595)
            at FtpDownloadDemo.main(FtpDownloadDemo.java:25)</p>
  </blockquote>