Package exercise.echo.client

Source Code of exercise.echo.client.EchoClient

package exercise.echo.client;

import java.rmi.Naming;
import java.rmi.RemoteException;
import exercise.echo.Echo;
import java.io.BufferedReader;
import java.io.InputStreamReader;
   
public class EchoClient {


  public static void main(String[] argv) {
   
    if(argv.length != 1) {
      usage();
      return;
    }
    String serverURL = argv[0];
   
    Echo echo  = null;  
    try {
      echo = (Echo)Naming.lookup(argv[0]);
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      while(true) {
  System.out.print("Type a string: ");
  String s = in.readLine();
  String reply = echo.reverse(s);
  System.out.println("The reply from " + serverURL + " is [" + reply + "].");
      }
    }
    catch (Exception e) {
      System.out.println("X exception: " + e.getMessage());
      e.printStackTrace();
    }
  }

  private
  static
  void usage() {
     System.err.println("Usage: exercise.echo.client.EchoClient SERVER_URL");    
  }
}
TOP

Related Classes of exercise.echo.client.EchoClient

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.