Example usage for org.apache.commons.net.ftp FTPReply FILE_STATUS_OK

List of usage examples for org.apache.commons.net.ftp FTPReply FILE_STATUS_OK

Introduction

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

Prototype

int FILE_STATUS_OK

To view the source code for org.apache.commons.net.ftp FTPReply FILE_STATUS_OK.

Click Source Link

Usage

From source file:org.apache.maven.wagon.providers.ftp.FtpWagon.java

public boolean resourceExists(String resourceName) throws TransferFailedException, AuthorizationException {
    Resource resource = new Resource(resourceName);

    try {//from   w w  w. j ava2s. c om
        ftpChangeDirectory(resource);

        String filename = PathUtils.filename(resource.getName());
        int status = ftp.stat(filename);

        return ((status == FTPReply.FILE_STATUS) || (status == FTPReply.DIRECTORY_STATUS)
                || (status == FTPReply.FILE_STATUS_OK) // not in the RFC but used by some FTP servers
                || (status == FTPReply.COMMAND_OK) // not in the RFC but used by some FTP servers
                || (status == FTPReply.SYSTEM_STATUS));
    } catch (IOException e) {
        throw new TransferFailedException("Error transferring file via FTP", e);
    } catch (ResourceDoesNotExistException e) {
        return false;
    }
}