Example usage for org.apache.commons.net.ftp FTPClient setFileType

List of usage examples for org.apache.commons.net.ftp FTPClient setFileType

Introduction

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

Prototype

public boolean setFileType(int fileType) throws IOException 

Source Link

Document

Sets the file type to be transferred.

Usage

From source file:uk.ac.manchester.cs.datadesc.validator.utils.UrlReader.java

private InputStream getInputStream(FTPClient ftp) throws VoidValidatorException {
    try {/*w  w w  .  j a v  a 2 s . c o m*/
        // in theory this should not be necessary as servers should default to ASCII
        // but they don't all do so - see NET-500
        ftp.setFileType(FTP.ASCII_FILE_TYPE);
        ftp.enterLocalPassiveMode();
        ftp.setUseEPSVwithIPv4(useEpsvWithIPv4);
        String path = uri.getPath();
        return ftp.retrieveFileStream(path);
    } catch (FTPConnectionClosedException ex) {
        disconnect(ftp);
        throw new VoidValidatorException("Server closed connection.", ex);
    } catch (IOException ex) {
        disconnect(ftp);
        throw new VoidValidatorException("IOEXception with Server ", ex);
    }
}