Try this out ....
This is working for me ..
Srinivasa Raghavan
import java.net.*;
import java.io.*;
class ftpClient
{
URLConnection connection;
InputStream is;
OutputStream os;
String url;String user;
String password;
public ftpClient(String url,String user,String password)
{
this.url =url;
this.user= user;
this.password=password;
}
private void getConnection(String file)
{
try
{
StringBuffer location = new StringBuffer();
location.append("ftp://");
location.append(user + ":");
location.append(password + "@");
location.append(url + "/");
location.append(file +";type=i");
connection = (new URL(location.toString())).openConnection();
is = connection.getInputStream();
}
catch(Exception e)
{
System.out.println(e.toString() + "Here" );
}
}
public void download( String inputFile,String outputFile ) throws Exception
{
try
{
getConnection( inputFile );
int data;
InputStreamReader fileReader = new InputStreamReader(is);
FileOutputStream writer = new FileOutputStream( new File(outputFile) );
while ( (data = fileReader.read()) != -1 )
{
writer.write((char)data);
}
}
catch(Exception e)
{
System.out.println(e );
}
}
public static void main(String[] args)
{
String inputFile = "home/srinivas/test/reverse.java";
String outputFile = "C:\\reverse.java";
try
{
ftpClient client = new ftpClient("20.10.3.225","test","password");
client.download(inputFile,outputFile);
System.out.println( inputFile + " downloaded successfully to " + outputFile);
}
catch(Exception e)
{
System.out.println(e);
}
}
}