Yes.
Here's the code , it uses the com.oroinc.net.ftp package , you can download it
from
http://www.savarese.org/oro/developers/docs/NetComponents/api/com.oroinc.net.ftp.FTPClient.html
import java.io.*;
import com.oroinc.net.ftp.*;
public final class ftp {
public ftp(String filename, String ftp_type)
{
boolean result , login_status;
FTPClient client;
String ftpfile;
client = new FTPClient();
try{
client.connect("servername.com");//replace servername with your server
if(!FTPReply.isPositiveCompletion(client.getReplyCode()))
{
client.disconnect();
System.err.println("FTP server refused connection");
return;
}
if ( client.isConnected() )
System.out.println("Connection Established");
login_status = client.login("userid","passowrd");
System.out.println("Login status "+login_status+client.getReplyString());
result = client.setFileType(com.oroinc.net.ftp.FTP.BINARY_FILE_TYPE);
System.out.println("FTP set file type status "+result);
if ( ftp_type.equalsIgnoreCase("send") )
{
result = client.storeFile("foldername/"+filename,new
FileInputStream(filename));
System.out.println("FTP store status "+result);
}
else
{
result = client.retrieveFile("foldername"+filename,new
FileOutputStream(filename));
System.out.println("FTP retrieve statusfor "+filename+" "+result);
System.out.println("FTP retrieve status "+client.getReplyString());
System.out.println("Reading index file to retrieve log files");
BufferedReader in = new BufferedReader( new FileReader(filename));
//retrieve each file found in the index file
while ( (ftpfile = in.readLine()) != null )
{
result = client.retrieveFile(ftpfile,new FileOutputStream(ftpfile));
System.out.println("FTP retrieve statusfor "+ftpfile+" "+result);
System.out.println("FTP retrieve status "+client.getReplyString());
}
}
client.quit();
client.disconnect();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
You may have to tweak it a bit to suit your requirement and environment
hope it helps
Santosh
Alexander Bonilla <[EMAIL PROTECTED]> on 05/18/2001 10:40:30 AM
Please respond to A mailing list about Java Server Pages specification and
reference <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (bcc: Santosh Daryani/IT/Aon Consulting)
Subject: Send and get flies by FTP
Hello!
Does anyone of you to know how to send and get files by FTP in Java?
Thanks,
Alex
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets