Example usage for org.apache.commons.net.ftp FTPFile toFormattedString

List of usage examples for org.apache.commons.net.ftp FTPFile toFormattedString

Introduction

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

Prototype

public String toFormattedString() 

Source Link

Document

Returns a string representation of the FTPFile information.

Usage

From source file:com.adaptris.ftp.ApacheFtpClientImpl.java

/**
 * list files in the current server directory
 *//*  www.j  a v a  2 s  .c  o  m*/
@Override
public String[] dir(String dirname, boolean full) throws IOException {
    String[] listing = new String[0];
    try {
        acquireLock();
        log("{} {}", FTPCmd.LIST, dirname);
        FTPFile[] results = ftpClient().listFiles(dirname);
        logReply(ftpClient().getReplyStrings());
        List<String> output = new ArrayList<String>();
        for (FTPFile file : results) {
            if (full) {
                output.add(file.toFormattedString());
            } else {
                output.add(file.getName());
            }
            listing = output.toArray(new String[output.size()]);
        }
    } finally {
        releaseLock();
    }
    return listing;
}

From source file:org.waarp.ftp.client.WaarpFtpClient.java

/**
 * // w w  w . j  a v a 2  s . c  om
 * @return the list of files as returned by the FTP command
 */
public String[] listFiles() {
    try {
        FTPFile[] list = this.ftpClient.listFiles();
        String[] results = new String[list.length];
        int i = 0;
        for (FTPFile file : list) {
            results[i] = file.toFormattedString();
            i++;
        }
        return results;
    } catch (IOException e) {
        result = "Cannot finalize transfer operation";
        logger.error(result, e);
        return null;
    }
}