Example usage for org.apache.commons.net.ftp FTPListParseEngine readServerList

List of usage examples for org.apache.commons.net.ftp FTPListParseEngine readServerList

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPListParseEngine readServerList.

Prototype

public void readServerList(InputStream stream, String encoding) throws IOException 

Source Link

Document

handle the initial reading and preparsing of the list returned by the server.

Usage

From source file:com.atomicleopard.thundr.ftp.commons.FTPClient.java

/**
 * private method through which all listFiles() and
 * initiateListParsing methods pass once a parser is determined.
 *
 * @exception FTPConnectionClosedException
 *                   If the FTP server prematurely closes the connection as a result
 *                   of the client being idle or some other reason causing the server
 *                   to send FTP reply code 421.  This exception may be caught either
 *                   as an IOException or independently as itself.
 * @exception IOException//from  ww w .j a va2s .c o m
 *                   If an I/O error occurs while either sending a
 *                   command to the server or receiving a reply from the server.
 * @see FTPListParseEngine
 */
private FTPListParseEngine initiateListParsing(FTPFileEntryParser parser, String pathname) throws IOException {
    Socket socket = _openDataConnection_(FTPCmd.LIST, getListArguments(pathname));

    FTPListParseEngine engine = new FTPListParseEngine(parser);
    if (socket == null) {
        return engine;
    }

    try {
        engine.readServerList(socket.getInputStream(), getControlEncoding());
    } finally {
        Util.closeQuietly(socket);
    }

    completePendingCommand();
    return engine;
}

From source file:com.atomicleopard.thundr.ftp.commons.FTPClient.java

/**
 * Initiate list parsing for MLSD listings.
 *
 * @param pathname/*  www .  java 2 s. c om*/
 * @return the engine
 * @throws IOException
 */
private FTPListParseEngine initiateMListParsing(String pathname) throws IOException {
    Socket socket = _openDataConnection_(FTPCmd.MLSD, pathname);
    FTPListParseEngine engine = new FTPListParseEngine(MLSxEntryParser.getInstance());
    if (socket == null) {
        return engine;
    }

    try {
        engine.readServerList(socket.getInputStream(), getControlEncoding());
    } finally {
        Util.closeQuietly(socket);
        completePendingCommand();
    }
    return engine;
}