Server class:
import java.net.*;
import java.io.*;
public class fileserver {
public static void main(String args []) {
ServerSocket ss=new ServerSocket(2345);
Socket s= ss.accept();
FileInputStream f=new FileInputStream("D:\\FEATURED.txt");
DataOutputStream dout= new DataOutputStream(s.getOutputStream);
byte[] b=new byte[2002];
f.read(b,0,b.length);
dout.write(b,0,b.length);
dout.close();
f.close();
s.close();
}
}
Client class:
import java.io.*;
import java.net.*;
public class clientserver {
public static void main(String args []) {
Socket s=new Socket("localhost",2345);
FileOutputStream f=new FileOutputStream("E:\\FEATUREDCOPIED.txt");
DataInputStream din= new DataInputStream(s.getInputStream);
byte[] b=new byte[2002];
din.read(b,0,b.length);
f.write(b,0,b.length);
din.close();
f.close();
s.close();
}
}
Error:
please help me to resolve this query.
getInputStream
and getOutputStream
are methods, so you must call them which means putting parenthesis after their name: s.getInputStream()
instead of just s.getInputStream
.