hi,
please provide the information about the how how to transfer file from to
another by using FTP in java..
please provide the source code
Printable View
hi,
please provide the information about the how how to transfer file from to
another by using FTP in java..
please provide the source code
Java FTP Examples Source Code
http://www.ajaxapp.com/2009/02/21/a-...ad-and-upload/
In google is much information about it.
tell me also how to transfer file...:(
this is a small program
the program is as follows
server program///
import java.io.*;
import java.net.*;
public lass ftps
{
public static void main(String ar[])
{
Socket s;
ServerSocket server;
FileInputStream fis;
BufferedReader br;
PrintWriter pw;
String filename;
int c;
try
{
server=new ServerSocket(1111);
System.out.println("server is waiting for the connection");
s=server.accept();
System.out.println("connection established");
br=new BufferedReader(new InputStreamReader(s.getInputStream()));
pw=new PrintWriter(s.getOutputStream());
filename=br.readLine();
fis=new FileInputStream(filename);
while((c=fis.read())!=-1)
{
pw.print((char)c);
pw.flush();
}
System.out.println("file copied");
s.close();
}
catch(Exception e)
{
System.out.println(e)
}
}
}
client program
import java.net.*;
import java.io.*;
public class cli
{
public static void main(String ar[])
{
Socket s;
BufferedReader br;
PrintWriter pw;
String spath,dpath;
FileOutputStream fos;
int c;
try
{
s=new Socket("localhost",1111);
in=new BufferedReader(new InputStreamReader(System.in));
br=new BufferedReader(new InputStreamReader(s.getInputStream()));
pw=new PrintWriter(s.getOutputStream());
System.out.println("enter the source");
spath=in.readLine();
System.out.println("enter the destination");
dpath=in.readLine();
fos=new FileOuptustream(dpath);
while((c=br.read())!=-1)
{
fos.write();
fos.flush();
}
System.out.println("file reached");
}
catch(Exception e)
{
System.out.println(e);
}
}
}