You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by murali krishnan <mu...@gmail.com> on 2014/03/20 14:15:55 UTC

[vfs]

Hi Team,



I have a question regarding the commons-net-3.3.jar. The below code snippet
is from FTPClient.java (available in commons-net-3.3-sources.jar). I am
calling the method retrieveFile to download a file from a FTP server. I
just want to know whether this stores the entire file content in the memory
or writes the file directly to the disk? Can you clarify my query please?



public boolean retrieveFile(String remote, OutputStream local)

    throws IOException

    {

        return _retrieveFile(FTPCmd.RETR.getCommand(), remote, local);

    }



    /**

     * @since 3.1

     */

    protected boolean _retrieveFile(String command, String remote,
OutputStream local)

    throws IOException

    {

        Socket socket = _openDataConnection_(command, remote);



        if (socket == null) {

            return false;

        }



        InputStream input = getBufferedInputStream(socket.getInputStream());

        if (__fileType == ASCII_FILE_TYPE) {

            input = new FromNetASCIIInputStream(input);

        }



        CSL csl = null;

        if (__controlKeepAliveTimeout > 0) {

            csl = new CSL(this, __controlKeepAliveTimeout,
__controlKeepAliveReplyTimeout);

        }



        // Treat everything else as binary for now

        try

        {

            Util.copyStream(input, local, getBufferSize(),

                    CopyStreamEvent.UNKNOWN_STREAM_SIZE,
__mergeListeners(csl),

                    false);

        } finally {

            Util.closeQuietly(input);

            Util.closeQuietly(socket);

            if (csl != null) {

                csl.cleanUp(); // fetch any outstanding keepalive replies

            }

        }



        // Get the transfer response

        boolean ok = completePendingCommand();

        return ok;

    }



Regards

Murali

Re: [vfs]

Posted by sebb <se...@gmail.com>.
On 20 March 2014 13:15, murali krishnan <mu...@gmail.com> wrote:
> Hi Team,

Is this about VFS? or about NET?

In any case, this is off-topic for the developer list.
Please subscribe to the user list and re-post there.

Please also use a subject that starts with the [name] of the component.
The rest of the subject line should provide some clue as what the
e-mail is about.
This makes it easier for people to help you, and easier for people
reading the archives to benefit from the thread.

>
>
> I have a question regarding the commons-net-3.3.jar. The below code snippet
> is from FTPClient.java (available in commons-net-3.3-sources.jar). I am
> calling the method retrieveFile to download a file from a FTP server. I
> just want to know whether this stores the entire file content in the memory
> or writes the file directly to the disk? Can you clarify my query please?
>
>
>
> public boolean retrieveFile(String remote, OutputStream local)
>
>     throws IOException
>
>     {
>
>         return _retrieveFile(FTPCmd.RETR.getCommand(), remote, local);
>
>     }
>
>
>
>     /**
>
>      * @since 3.1
>
>      */
>
>     protected boolean _retrieveFile(String command, String remote,
> OutputStream local)
>
>     throws IOException
>
>     {
>
>         Socket socket = _openDataConnection_(command, remote);
>
>
>
>         if (socket == null) {
>
>             return false;
>
>         }
>
>
>
>         InputStream input = getBufferedInputStream(socket.getInputStream());
>
>         if (__fileType == ASCII_FILE_TYPE) {
>
>             input = new FromNetASCIIInputStream(input);
>
>         }
>
>
>
>         CSL csl = null;
>
>         if (__controlKeepAliveTimeout > 0) {
>
>             csl = new CSL(this, __controlKeepAliveTimeout,
> __controlKeepAliveReplyTimeout);
>
>         }
>
>
>
>         // Treat everything else as binary for now
>
>         try
>
>         {
>
>             Util.copyStream(input, local, getBufferSize(),
>
>                     CopyStreamEvent.UNKNOWN_STREAM_SIZE,
> __mergeListeners(csl),
>
>                     false);
>
>         } finally {
>
>             Util.closeQuietly(input);
>
>             Util.closeQuietly(socket);
>
>             if (csl != null) {
>
>                 csl.cleanUp(); // fetch any outstanding keepalive replies
>
>             }
>
>         }
>
>
>
>         // Get the transfer response
>
>         boolean ok = completePendingCommand();
>
>         return ok;
>
>     }
>
>
>
> Regards
>
> Murali

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