Results 1 to 2 of 2
  1. #1
    magi1982 is offline Member
    Join Date
    Jan 2012
    Posts
    1
    Rep Power
    0

    Default FTPclient is driving me nuts! please advise!

    Hi all,

    I am currently working on a project which involves the Edgar SEC database (a public database owned by the USA gov. see link for explanation: Information for FTP Users ). I am trying to download certain files from it using FTPclient but it is not working! Eclipse returns the following code when i run the script. I have googled arround and did not found a conclusive answer. Please have a look and give me some suggestions!

    Java Code:
    java.net.SocketException: Software caused connection abort: recv failed
    	at java.net.SocketInputStream.socketRead0(Native Method)
    	at java.net.SocketInputStream.read(Unknown Source)
    	at java.net.SocketInputStream.read(Unknown Source)
    	at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
    	at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
    	at sun.nio.cs.StreamDecoder.read(Unknown Source)
    	at java.io.InputStreamReader.read(Unknown Source)
    	at java.io.BufferedReader.fill(Unknown Source)
    	at java.io.BufferedReader.read(Unknown Source)
    	at org.apache.commons.net.io.CRLFLineReader.readLine(CRLFLineReader.java:58)
    	at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:310)
    	at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:290)
    	at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:474)
    	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._openDataConnection_(FTPClient.java:667)
    	at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2990)
    	at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2965)
    	at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2623)
    	at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2670)
    	at NERV.initiateNerv.alternativeFTP(initiateNerv.java:615)
    	at NERV.initiateNerv.main(initiateNerv.java:646)

    Java Code:
    import org.apache.commons.net.ftp.FTP;
    import org.apache.commons.net.ftp.FTPFile;
    import org.apache.commons.net.ftp.FTPClient;
    
    private static void FTP(){
    			    
    	   String edgarServer ="ftp.sec.gov";
    	    
    	   String directory = "//edgar";
    	   
    	    try {
    	    	
    	    	FTPClient edgarFTP = new FTPClient();
    	    		    	
    	    	int reply;
    	    	edgarFTP.connect(edgarServer);    	
    	    	edgarFTP.setRemoteVerificationEnabled(false);
    	    	System.out.println("Connected to EDGAR");
    	    	System.out.print(edgarFTP.getReplyString());
    	  
    	    	reply = edgarFTP.getReplyCode();
    
    		      if(!FTPReply.isPositiveCompletion(reply)) {
    		    	  edgarFTP.disconnect();
    		    	  System.err.println("FTP server refused connection.");
    		    	  System.exit(1);
    		      }
    		 
    		      FileOutputStream fos = null;
    		      String filename = "README.txt";		      
    		      fos = new FileOutputStream("C:\\"+filename);
    		      
    		      
    		      edgarFTP.retrieveFile(directory+"/" + filename, fos); //pull ftp.sec.gov/edgar/README.txt (it does nothing at all..)
    		     
    		     		      
    		      FTPFile[] files = edgarFTP.listFiles(); //list all files (returns the error as mentioned above)
    
    	      edgarFTP.logout();
    	      edgarFTP.disconnect();
    	      
    	    } catch(IOException e) {
    	      error = true;
    	      e.printStackTrace();
    	    } 
    		
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: FTPclient is driving me nuts! please advise!

    The stack trace does not seem to show any references to your code.

Similar Threads

  1. Image sizing is driving me nuts!!!
    By knightwriter in forum New To Java
    Replies: 3
    Last Post: 12-30-2011, 05:02 PM
  2. Syntax error driving me nuts
    By CeeLove in forum Java Applets
    Replies: 2
    Last Post: 03-25-2011, 10:15 AM
  3. FTPClient need to download?
    By dudejonne in forum New To Java
    Replies: 8
    Last Post: 11-06-2009, 04:40 PM
  4. problems sun.net.ftp.FtpClient
    By tommy in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 04:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •