You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mailing User <ma...@mail.com> on 2016/05/01 17:16:02 UTC

[FTP] Create new client for retrieveFileStream()?

I searched Google for examples uses of Apache Commons FTP library, but only found very basic examples. For efficiency and not to reach user limit, I used only one client.

When I called mlistFile(), I got an "java.lang.ArrayIndexOutOfBoundsException: length=1; index=1." at
    String entry = getReplyStrings()[1].substring(1); 

I found that at that time, getReplyStrings returned a String array that had only one element, and it was
    226 Successfully transferred "/somefile.mp4"
instead of the expected
    250-Listing /somefile.mp4
     type=file;size=1834618;modify=20090501101746; /somefile.mp4
    250 End
 
It seems that the response for MLST was mixed with a file close (InputStream.close()) response. What is the best way to avoid this? Should I use a separate client for retrieveFileStream()?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [FTP] Create new client for retrieveFileStream()?

Posted by sebb <se...@gmail.com>.
On 1 May 2016 at 16:16, Mailing User <ma...@mail.com> wrote:
> I searched Google for examples uses of Apache Commons FTP library, but only found very basic examples. For efficiency and not to reach user limit, I used only one client.
>
> When I called mlistFile(), I got an "java.lang.ArrayIndexOutOfBoundsException: length=1; index=1." at
>     String entry = getReplyStrings()[1].substring(1);
>
> I found that at that time, getReplyStrings returned a String array that had only one element, and it was
>     226 Successfully transferred "/somefile.mp4"
> instead of the expected
>     250-Listing /somefile.mp4
>      type=file;size=1834618;modify=20090501101746; /somefile.mp4
>     250 End
>
> It seems that the response for MLST was mixed with a file close (InputStream.close()) response. What is the best way to avoid this? Should I use a separate client for retrieveFileStream()?

The Javadoc

http://commons.apache.org/proper/commons-net/javadocs/api-3.4/org/apache/commons/net/ftp/FTPClient.html#retrieveFileStream(java.lang.String)

says:

"To finalize the file transfer you must call completePendingCommand
and check its return value to verify success. If this is not done,
subsequent commands may behave unexpectedly. "



> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org