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

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

Introduction

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

Prototype

int FILE_STATUS

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

Click Source Link

Usage

From source file:edu.monash.merc.system.remote.FTPFileGetter.java

/**
 * Issue the FTP MDTM command (not supported by all servers to retrieve the last modification time of a file.
 * The modification string should be in the ISO 3077 form "YYYYMMDDhhmmss(.xxx)?".
 * The timestamp represented should also be in GMT, but not all FTP servers honour this.
 *
 * @param remoteFile The file path to query.
 * @return A string representing the last file modification time in YYYYMMDDhhmmss format.
 *///from  www  .  jav a  2s. c  o  m
public String getLastModifiedTime(String remoteFile) {
    try {
        String replyCode = getModificationTime(remoteFile);
        String tempTime = StringUtils.substringAfter(replyCode, String.valueOf(FTPReply.FILE_STATUS));
        return StringUtils.trim(tempTime);
    } catch (Exception ex) {
        throw new DMFTPException(ex);
    }
}

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 {// www.  ja  v  a2s.  com
        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;
    }
}