Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.6k views
in Java FTP by (160 points)
i hope this isn't already posted or i didn't read the api well

i tried this:
import com.enterprisedt.net.ftp.FTPClient;

public class FtpExample {
    private FTPClient ftp;

public void download() {
try {
   ftp.setRemoteHost("host");
   ftp.connect();
   ftp.login("username","password");
   ftp.get("C:\\blubb\\288.JPG","/testi/test/288.JPG");
   ftp.quit();
} catch(Exception e) {

}


and i tried this:
import java.io.FileOutputStream;
import com.enterprisedt.net.ftp.FTPClient;

public class FtpExample {
    private FTPClient ftp;

public void download() {
try {
   ftp.setRemoteHost("host");
   ftp.connect();
   ftp.login("username","password");
   FileOutputStream stream = new FileOutputStream("C:\\blubb\\288.JPG");
   ftp.get(stream,"/testi/test/288.JPG");
   ftp.quit();
} catch(Exception e) {

}


it works but the result isn't good,
this is the right picture:
[ img ]
that is the downloaded one:
[ img ]


EDIT: i used the free version, please help me, i think it is my bad, do i have to set anything?

2 Answers

0 votes
by (162k points)
You are transferring in ASCII (text) mode, which is the default for most servers.

You need to transfer binary files in binary mode. Try using ftp.setType(FTPTransferType.BINARY) before transferring the binary file.
0 votes
by (160 points)
thank you very much, it works fine

Categories

...