I am sorry if this is a stupid questions, but I am having issues with
commons-net corrupting downloaded .zip files. Here is my setup:
Client:
Ubuntu 10.04 64bit
java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)
I am using commons-net-2.0
All I am trying to do is connect to a ftp server and download a .zip
file. I have tried from two different ftp servers including a netware
6.5 and an Ubuntu 8.04 LTS server and they both corrupt the file.
The application runs and all looks well until I do a md5sum on the
file.
I get:
3c8d305a4e30592f0ac89fd1f2ce7556 Known Good file
50855164b0b0224521e930d8324742d3 Downloaded File
2591697 Known Good file
2591639 Downloaded File
On our netware server I tried setting:
FTPClientConfig conf = new
FTPClientConfig(FTPClientConfig.SYST_NETWARE);
ftp.configure(conf);
But it didn't seem to make a difference.
Any help would be greatly appreciated.
here is my code
==========
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
public class Main
{
public static void main(String[] args)
{
boolean error = false;
FTPClient ftp = null;
try
{
int reply;
ftp=new FTPClient();
ftp.connect("database.dupage88.net");
ftp.login("csyperski", "password");
System.out.print(ftp.getReplyString());
reply = ftp.getReplyCode();
if(!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
System.err.println("FTP server refused connection.");
System.exit(1);
}
ftp.setFileTransferMode(FTPClient.BINARY_FILE_TYPE);
System.out.println( ftp.printWorkingDirectory() );
ftp.retrieveFile("VMS.zip",new
FileOutputStream( "/tmp/vms.zip"));
ftp.logout();
}
catch(IOException e)
{
error = true;
e.printStackTrace();
}
finally
{
if(ftp.isConnected())
{
try
{
ftp.disconnect();
}
catch(IOException ioe)
{
}
}
System.exit(error ? 1 : 0);
}
}
}
==========
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]