Person p = new Person();
}
public Person(){
try {
//得到文件对象
File f1 = new File("D:\\Program Files\\eclipse中文\\Turing\\u\\src\\g.java");
//创建输入,字节流
FileInputStream fis = new FileInputStream(f1);
Object o = fis.read();
Socket s1 = new Socket("127.0.0.1",9999);
ObjectOutputStream oos=new ObjectOutputStream(s1.getOutputStream());
oos.writeObject(o);
public class Server {
public static void main(String[] args) {
Server server = new Server();
}
public Server(){
//服务器端在监听9999端口
System.out.println("我是服务器我在9999监听........");
try {
ServerSocket ss = new ServerSocket(9999);
Socket s = ss.accept();
//接收客户端发来的信息
ObjectInputStream ois= new ObjectInputStream(s.getInputStream());
System.out.println("客户端发来的消息为:"+ois.readObject().toString());