0

I'm trying to download files from FTP on Java using org.apache.commons.

try {
        OutputStream os = new FileOutputStream(downloadedFile);
        boolean success = this.client.retrieveFile(from, os);
        System.out.println("File transfer status is "+ Boolean.toString(success));
        os.close();
    } catch (IOException e) {
        System.err.println(e.getMessage());
    }

And files are downloading, but some images have error like Invalid image, another looks like that https://www.dropbox.com/s/faozfxzag5xrk5z/Screenshot_3.png

Any ideas? Thx

ibm701
  • 305
  • 2
  • 11

1 Answers1

0

Try setting file type to binary, ie:

client.setFileType(FTP.BINARY_FILE_TYPE);

FTPClient has default settings to use FTP.ASCII_FILE_TYPE.

tenorsax
  • 21,123
  • 9
  • 60
  • 107