SOURCE CODE for finger client which fingers the given server

import java.net.*;
import java.io.*;

public class finger {

// a Java command-line finger client

   public final static int port = 79;

   public static void main(String[] args) {

	Socket theSocket;
	String hostname;
	DataInputStream theFingerStream;
	PrintStream ps;



	try
	{	hostname = args[0];	}
	catch (Exception e)
	{	hostname = "localhost";	}


	try {
		theSocket = new Socket(hostname, port, true);
		ps = new PrintStream(theSocket.getOutputStream());
		for (int i = 1; i < args.length; i++) ps.print(args[i] + " ");
		ps.print("\r\n");
		theFingerStream = new DataInputStream(theSocket.getInputStream());
		String str;
		while ((str = theFingerStream.readLine()) != null)
		{	System.out.println(str);	}
	}
	catch (IOException e)
		{	System.err.println(e);	}
   }
}