Using TCP/IP sockets, write a client ‒ server program to
make the client send the file name and to make the server
send back the contents of the requested file if present
import [Link].*;
import [Link].*;
public class ftpclient {
public static void main(String args[]) {
Socket s;
BufferedReader in, br;
PrintWriter pw;
String spath, dpath;
FileOutputStream fos;
int c;
try {
s = new Socket("localhost", 1111);
in = new BufferedReader(new InputStreamReader([Link]));
br = new BufferedReader(new InputStreamReader([Link]()));
pw = new PrintWriter([Link](), true);
[Link]("\nEnter source file to be copied:");
spath = [Link]();
[Link]("\nEnter destination path to transfer:");
dpath = [Link]();
fos = new FileOutputStream(dpath);
[Link](spath);
while ((c = [Link]()) != -1) {
[Link]((char) c);
[Link]();
}
[Link]("File Transfer Completed");
}
catch (Exception e) {
[Link](e);
}
}
}