Thanks. I did that and it worked :)
----- Original Message ---- From: Rory Winston <[EMAIL PROTECTED]> To: Jakarta Commons Developers List <dev@commons.apache.org> Sent: Friday, October 12, 2007 6:39:02 PM Subject: Re: Error while downloading zip file using commons-net 1.4.1 Try setting the file type explicitly to binary. Rory s n wrote: > Hi All, > > I am trying to use the commons-net (1.4.1) package to download zip files from and FTP site.Everything seems to be working fine (Able to login and download the file), except when i try to open the downloaded zip file. > > I am not sure why this happens. Any help would be highly appreciated. > > I have pasted the error and my code below: > > Thanks! > > > > I get the following error (winzip spits out this error) > ###################################################################### > ERROR: > Extracting to "C:\DOCUME~1\sn\LOCALS~1\Temp\" > Use Path: no Overlay Files: yes > warning [C:/MeV/APPLERA_ABI1700.zip]: extra 14052 bytes at beginning or within Zip file (attempting to process anyway) > Error in file #1: bad Zip file offset (Error local header signature not found): 0 > (attempting to re-compensate) > Extracting APPLERA_ABI1700 > (incomplete d-tree) Error: invalid compressed data to inflate > ####################################################################### > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > CODE; > public class TestFTP { > > /** > * @param args > */ > public static void main(String[] args) throws Exception{ > > try { > > String folder="/pub/bio/tgi/data/Resourcerer/"; > FTPClient ftp = new FTPClient(); > > FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_NT); > ftp.configure(conf); > > ftp.connect(InetAddress.getByName("occams.dfci.harvard.edu")); > > System.out.print("Server response:"+ftp.getReplyString()); > int reply = ftp.getReplyCode(); > > if(!FTPReply.isPositiveCompletion(reply)) { > System.err.println("FTP server refused connection."); > ftp.disconnect(); > System.exit(1); > > } > > if(!ftp.login("username", "password")) { > System.err.println(); > } > > ftp.changeWorkingDirectory("/ftp/pub/bio/tgi/data/Resourcerer/Human/"); > > // List the zip files in the directory > String[]names=ftp.listNames("*.zip"); > > File f=new File("C:/MeV/"+names[0]); > FileOutputStream temp=new FileOutputStream(f); > ftp.retrieveFile(f.getName(), temp); > System.out.println("size of downloaded file is:"+f.length()); > temp.close(); > > ftp.logout(); > }catch(Exception e) { > e.printStackTrace(); > } > > // TODO Auto-generated method stub > > } > > } > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > > > > > ____________________________________________________________________________________ > Shape Yahoo! in your own image. Join our Network Research Panel today! http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com