commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Susanta Mohapatra <mohapatra.susa...@gmail.com>
Subject Re: [NET] FTP Client not fetching file with german umclaut characheters
Date Fri, 15 Jun 2012 13:33:40 GMT
Thanks a lot Torsten !!

Your suggested code changes worked ..  I am quite new to this FTPClient API
and this was a good learning for me.

Thanks
Susanta

On Fri, Jun 15, 2012 at 6:15 PM, Torsten Krah <
tkrah@fachschaft.imn.htwk-leipzig.de> wrote:

> You must be careful at which time in the "ftp process" you issue a
> command (the javadoc of most methods does tell this).
>
> E.g. setting control encoding or UTF-8 auto detection must be done
> before "connect" is called -  because of that it does fail in your case;
> the socket is already opened and setup is done in your example and you
> are calling things "too late" to have an effect.
>
> I did used you code and changed things like this:
>
>    FTPClient ftp = new FTPClient();
>    ftp.setAutodetectUTF8(true);
>    ftp.connect(host);
>    ftp.login("xx", "xx");
>    ftp.enterLocalPassiveMode();
>    ftp.setFileType(FTP.BINARY_FILE_TYPE);
>
>    ....
>
>    String resource = "sozial-fähigen-Anwendungen.txt";
>     InputStream is = ftp.retrieveFileStream(resource);
>    reply = ftp.getReplyCode();
>     if (!FTPReply.isPositiveCompletion(reply) && reply !=
> FTPReply.FILE_STATUS_OK) {
>      System.out.println("Reply===>" + reply);
>      if(is != null) {
>      is.close();
>      }
>
>
>    ....
>
> console output:
>
> Connected to $HOST.
> 200 Switching to Binary mode.
> Change dir ok: true
> Stream1 status: 226 Transfer complete.
> Stream: org.apache.commons.net.io.SocketInputStream@79f6f296
>
> Used commons-net-3.0.1 for this example.
>
> Give this a try and report if it does work for you now too :-D.
>
> kind regards
>
> Torsten
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message