Code example for ObjectInputStream

Methods: close, readUTF

0
		String message = null;
 
		try { 
			socket= new Socket (InetAddress.getLocalHost(), 50000);
			out= new ObjectOutputStream (socket.getOutputStream());
			in= new ObjectInputStream (socket.getInputStream());
			System.out.println("Client: Connection established - sending message");
			 
			out.writeUTF ("Hello Server");
			out.flush();
			message= in.readUTF();
			System.out.println("Client - Message from Server: " + message);
 
			in.close(); 
			out.close(); 
			socket.close();
		} 
		catch(Exception e) {
			e.printStackTrace();
		} 
	}