|
-
February 9th, 2008, 02:14 PM
#8
Re: Download directory using FTP
Ok guys, as HackmanC suggested I used apache common jar files and I managed to open ftp connections. Now I have another question. The sample code I found downloads a file and its sth like this:
Code:
ftp.connect(server);
...
reply = ftp.getReplyCode();
...
if (!ftp.login(username, password)) {
ftp.logout();
}
else
{
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.enterLocalPassiveMode();
OutputStream output;
output = new FileOutputStream(fileNameTarget);
if (ftp.retrieveFile(pathToDownload, output))
System.out.println("FILE DOWNLOADED!");
else
System.out.println("A PROBLEM OCCURED WHILE TRYING TO DOWNLOAD THE FILE!");
output.close();
ftp.logout();
}
...
OK this works fine, but I was wondering if I can change the port on which the ftp client is connected. I suppose the above code uses by default, port 21. Can I change the port?
Thanx in advance,
THeodore
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|