You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Rory Winston (JIRA)" <ji...@apache.org> on 2008/02/18 00:58:34 UTC

[jira] Closed: (NET-176) Incorrect downloading binary files from FTP

     [ https://issues.apache.org/jira/browse/NET-176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rory Winston closed NET-176.
----------------------------

    Resolution: Cannot Reproduce

> Incorrect downloading binary files from FTP
> -------------------------------------------
>
>                 Key: NET-176
>                 URL: https://issues.apache.org/jira/browse/NET-176
>             Project: Commons Net
>          Issue Type: Bug
>    Affects Versions: 1.4
>         Environment: WinXP SP2, JDK 1.5, Commons.Net 1.4.
> Remote FTP Server (ProFTPd, Linux).
>            Reporter: Dmitriy Komarov
>
> When I am trying to download some archive files (.zip), they are stored sometimes on my PC wrong (damaged).
> Works _always_ good with Gene6 FTP Server (local) on WinXP SP2.
> Works _always_ bad with ProFTPd (remote!!!) on Linux.
> Example of code, based on Commons.Net:
> FTPClient c = new FTPClient();
> c.connect(host);
> c.enterRemotePassiveMode();
> c.setFileType(FTP.BINARY_FILE_TYPE);
> c.login(user, pass);
> c.changeWorkingDirectory(dir);
> FileOutputStream fos = new FileOutputStream(outFile);
> c.retrieveFile(fileName, fos);
> fos.close();
> c.disconnect();
> Example of code, successfuly working (not based on Commons.Net, just standart JDK modules):
> URL ur = new URL("ftp://" + user+ ":" + pass + "@" + host + "/" + dir + "/" + fileName);
> URLConnection urlc = ur.openConnection();
> BufferedInputStream bis = new BufferedInputStream(urlc.getInputStream());
> BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outFile));
> int by;
> while ((by = bis.read()) != -1)
>            bos.write(by);
> bis.close();
> bos.close();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.