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

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

Introduction

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

Prototype

@Override
public String toString() 

Source Link

Document

Returns a string representation of the FTPFile information.

Usage

From source file:com.sos.VirtualFileSystem.FTP.SOSVfsFtp.java

/**
 * return a listing of a directory in long format on
 * the remote machine//from  w  ww .  j av a  2s .  c  om
 *
 * @param pathname on remote machine
 * @return a listing of the contents of a directory on the remote machine
 * @exception Exception
 * @see #nList()
 * @see #nList( String )
 * @see #dir()
 */
@Override
public SOSFileList dir(final String pathname, final int flag) {
    @SuppressWarnings("unused")
    final String conMethodName = conClassName + "::dir";

    SOSFileList fileList = new SOSFileList();
    FTPFile[] listFiles = null;
    try {
        listFiles = Client().listFiles(pathname);
    } catch (IOException e) {
        RaiseException(e, HostID(SOSVfs_E_0105.params(conMethodName)));
    }
    for (FTPFile listFile : listFiles) {
        if (flag > 0 && listFile.isDirectory()) {
            fileList.addAll(this.dir(pathname + "/" + listFile.toString(), flag >= 1024 ? flag : flag + 1024));
        } else {
            if (flag >= 1024) {
                fileList.add(pathname + "/" + listFile.toString());
            } else {
                fileList.add(listFile.toString());
            }
        }
    }
    return fileList;
}

From source file:com.sos.VirtualFileSystem.FTP.SOSVfsFtpBaseClass.java

/**
 * return a listing of a directory in long format on
 * the remote machine//from  ww  w  . j  av  a2 s . c  o  m
 *
 * @param pathname on remote machine
 * @return a listing of the contents of a directory on the remote machine
 * @exception Exception
 * @see #nList()
 * @see #nList( String )
 * @see #dir()
 */
@Override
public SOSFileList dir(final String pathname, final int flag) {
    SOSFileList fileList = new SOSFileList();
    FTPFile[] listFiles;
    try {
        listFiles = Client().listFiles(pathname);
    } catch (IOException e) {
        throw new RuntimeException(SOSVfs_E_128.params("listfiles", "dir"), e);
    }
    for (FTPFile listFile : listFiles) {
        if (flag > 0 && listFile.isDirectory()) {
            fileList.addAll(this.dir(pathname + "/" + listFile.toString(), flag >= 1024 ? flag : flag + 1024));
        } else {
            if (flag >= 1024) {
                fileList.add(pathname + "/" + listFile.toString());
            } else {
                fileList.add(listFile.toString());
            }
        }
    }
    return fileList;
}

From source file:org.jboss.ejb3.examples.ch06.filetransfer.FileTransferBean.java

@Override
public String pwd() {
    // Get the client
    final FTPClient client = this.getClient();

    // Exec pwd//from   www  .  j  a v a2 s . co m
    try {
        final FTPFile[] files = client.listFiles();
        for (final FTPFile file : files) {
            log.info(file.toString());
        }

        // Exec pwd
        String dir = client.printWorkingDirectory();
        String separator = File.separator;

        if ("\\".equals(separator)) {
            // reformat to use for windows
            if (dir.startsWith("/")) {
                dir = dir.substring(1);
            }
            dir = dir.replaceAll("/", "\\" + separator);
        }

        return dir;

    } catch (final IOException ioe) {
        throw new FileTransferException("Could not print working directory", ioe);
    }
}

From source file:sos.net.SOSFTP.java

/**
 * return a listing of a directory in long format on
 * the remote machine//from ww w .j  a v a2s . c o  m
 * @param pathname on remote machine
 * @return a listing of the contents of a directory on the remote machine
 * @exception Exception
 * @see #nList()
 * @see #nList( String )
 * @see #dir()
 * @deprecated
 */
@Deprecated
public Vector<String> dir(final String pathname, final int flag) throws Exception {

    Vector<String> fileList = new Vector<String>();
    FTPFile[] listFiles = listFiles(pathname);
    for (FTPFile listFile : listFiles) {
        if (flag > 0 && listFile.isDirectory()) {
            fileList.addAll(this.dir(pathname + "/" + listFile.toString(), flag >= 1024 ? flag : flag + 1024));
        } else {
            if (flag >= 1024) {
                fileList.add(pathname + "/" + listFile.toString());
            } else {
                fileList.add(listFile.toString());
            }
        }
    }
    return fileList;
}