Java NetWorking: Simple Server and Client program

Help me track down this error please!

Page 1 of 1

1 Replies - 1133 Views - Last Post: 04 November 2009 - 12:31 PM Rate Topic: -----

#1 mdhol  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 03-November 09

Java NetWorking: Simple Server and Client program

Post icon  Posted 04 November 2009 - 07:33 AM

Hello,

I am trying to get a very simple FileSerrver / FileClient program to run properly. I have pulled the code from the internet and intend to modify it to complete an assignment. Everything looks kosher - at least to me - but when I run it I keep getting a null pointer exception.

The code is extremely well commented but in a nutshell what its supposed to do is this. You should be able to open a command line window, type "java FileServer C:\" and the server will then wait for a connection request. You should now be able to open a second command line window and type "java FileClient localhost" to return a directory of files, and then to download a file, run the client again with "java FileClient localhost t.txt". The file should be copied from the server to the client. I am doing everything locally and it works fine insofar as returning a directory index goes. It's when I try to have the client download a file that the * client code * throws an exception.

If someone could fix this for me, I'd be extremely grateful. I need to move on and build a GUI etc for this and have been banging my head against the wall on this error for far too long now.

Thanks!

import java.net.*;
import java.io.*;
   
/**
 * This program is a client for the FileServer server.  The 
 * server has a list of available text files that can be
 * downloaded by the client.  The client can also download
 * the list of files.  When the connection is opened, the
 * client sends one of two possible commands to the server:
 * "index" or "get <file-name>".  The server replies to
 * the first command by sending the list of available files.
 * It responds to the second with a one-line message,
 * either "ok" or "error".  If the message is "ok", it is
 * followed by the contents of the file with the specified
 * name.  The "error" message indicates that the specified
 * file does not exist on the server.  (The server can also
 * respond with the message "unknown command" if the command
 * it reads is not one of the two possible legal commands.)
 * 
 * The client program works with command-line arguments.
 * The first argument must be the name or IP address of the
 * computer where the server is running.  If that is the
 * only argument on the command line, then the client
 * gets the list of files from the server and displays
 * it on standard output.  If there are two parameters,
 * the second parameter is interpreted as the name of a
 * file to be downloaded.  A copy of the file is saved
 * as a local file of the same name, unless a file of
 * the same name already exists.  If there are three
 * arguments, the second is the name of the file to be
 * downloaded and the third is the name under which the
 * local copy of the file is to be saved.  This will
 * work even if a file of the same name already exists.
 */
public class FileClient {

   static final int LISTENING_PORT = 8000;

   public static void main(String[] args) {
   
	  String computer;		  // Name or IP address of server.
	  Socket connection;		// Socket for communicating with that computer.
	  PrintWriter outgoing;	 // Stream for sending a command to the server.
	  BufferedReader incoming;  // Stream for reading data from the connection.
	  String command;		   // Command to send to the server.
	  

	  /* Check that the number of command-line arguments is legal.
		 If not, print a usage message and end. */
	  
	  if (args.length == 0 || args.length > 3) {
		 System.out.println("Usage:  java FileClient <server>");
		 System.out.println("	or  java FileClient <server> <file>");
		 System.out.println(
			   "	or  java FileClient <server> <file> <local-file>");
		 return;
	  }
	  
	  /* Get the server name and the message to send to the server. */
	  
	  computer = args[0];
	  
	  if (args.length == 1)
		 command = "index";
	  else
		 command = "get " + args[1];
	  
	  /* Make the connection and open streams for communication.
		 Send the command to the server.  If something fails
		 during this process, print an error message and end. */
	  
	  try {
		 connection = new Socket( computer, LISTENING_PORT );
		 incoming = new BufferedReader( 
						   new InputStreamReader(connection.getInputStream()) );
		 outgoing = new PrintWriter( connection.getOutputStream() );
		 outgoing.println(command);
		 outgoing.flush();
	  }
	  catch (Exception e) {
		 System.out.println(
			  "Can't make connection to server at \"" + args[0] + "\".");
		 System.out.println("Error:  " + e);
		 return;
	  }
	  
	  /* Read and process the server's response to the command. */
	  
	  try {
		 if (args.length == 1) {
			   // The command was "index".  Read and display lines
			   // from the server until the end-of-stream is reached.
			System.out.println("File list from server:");
			while (true) {
			   String line = incoming.readLine();
			   if (line == null)
				   break;
			   System.out.println("   " + line);
			}
		 }
		 else {
			   // The command was "get <file-name>".  Read the server's
			   // response message.  If the message is "ok", get the file.
			String message = incoming.readLine();
			if (! message.equals("ok")) {
			   System.out.println("File not found on server.");
			   return;
			}
			PrintWriter fileOut;  // For writing the received data to a file.
			if (args.length == 3) {
				  // Use the th/ird parameter as a file name.
			   fileOut = new PrintWriter( new FileWriter(args[2]) );
			 
			}
			else {
				  // Use the second parameter as a file name,
				  // but don't replace an existing file.
				File file = new File(args[1]);
				if (file.exists()) {
				   System.out.println("A file with that name already exists.");
				   System.out.println("To replace it, use the three-argument");
				   System.out.println("version of the command.");
				   return;
				}
				fileOut = new PrintWriter( new FileWriter(args[1]) );
			}
			while (true) {
				   // Copy lines from incoming to the file until
				   // the end of the incoming stream is encountered.
				String line = incoming.readLine();
				if (line == null)
					break;
				fileOut.println(line);
			}
			if (fileOut.checkError()) {
			   System.out.println("Some error occurred while writing the file.");
			   System.out.println("Output file might be empty or incomplete.");
			}
		 }
	  }
	  catch (Exception e) {
		 System.out.println(
				 "Sorry, an error occurred while reading data from the server.");
		 System.out.println("Error: " + e);
	  }
	  finally {
		 try {
			connection.close();
		 }
		 catch (IOException e) {
		 }
	  }
	  
   }  // end main()
   

} //end class FileClient



Here is the ConnectionHandler
import java.net.*;
import java.io.*;

public class ConnectionHandler extends Thread {
	File directory;
	Socket connection;
	TextReader incoming;
	PrintWriter outgoing;
	
	ConnectionHandler(File dir, Socket conn) 
	{
		directory = dir;
		connection = conn;
		start();
	}
	
	void sendIndex() throws Exception 
	{
		// called by run in response to index command
		// sends list of files in directory
		String[] fileList = directory.list();
		for(int i = 0; i < fileList.length; i++)
			outgoing.println(fileList[i]);
			
		outgoing.flush();
		outgoing.close();
		
		if(outgoing.checkError())
			throw new Exception("Transmission Error.");
	}
	
	void sendFile(String fileName) throws Exception
	{
		// called by run in response to get<fileName>
		File file = new File(directory, fileName);
		
		if((!file.exists()) || file.isDirectory())
		{
			outgoing.println("Error!");
		}
		else
		{
			outgoing.println("OK");
			TextReader fileIn = new TextReader(new FileReader(file));
			while(fileIn.peek() != '/0') 
			{
				String line = fileIn.getln();
				outgoing.println(line);
			}
			outgoing.flush();
			outgoing.close();
			
			if(outgoing.checkError())
				throw new Exception("Transmission Error!");
		}
	}
	
	public void run()
	{
		// executed by the thread
		// creates communication streams, reads, executes cmd
		String command = "Command not read";
		
		try
		{
			incoming = new TextReader(connection.getInputStream());
			outgoing = new PrintWriter(connection.getOutputStream());
			command = incoming.getln();
			
			if(command.equals("index"))
			{
				sendIndex();
			}
			else if(command.startsWith("get"))
			{
				String fileName = command.substring(3).trim();
				sendFile(fileName);
			}
			else
			{
				outgoing.println("Unknown Command!");
				outgoing.flush();
			}
			System.out.println("OK	" + connection.getInetAddress() +
				" " + command + " " + command);
		}
		catch(Exception e)
		{
			System.out.println("ERROR " + connection.getInetAddress() +
				" " + command + " " + e);
		}
		finally
		{
			try
			{
				connection.close();
			}
			catch(IOException e)
			{
				
			}
		}
	}
}



Here is the FileClient:
import java.net.*;
import java.io.*;
   
/**
 * This program is a client for the FileServer server.  The 
 * server has a list of available text files that can be
 * downloaded by the client.  The client can also download
 * the list of files.  When the connection is opened, the
 * client sends one of two possible commands to the server:
 * "index" or "get <file-name>".  The server replies to
 * the first command by sending the list of available files.
 * It responds to the second with a one-line message,
 * either "ok" or "error".  If the message is "ok", it is
 * followed by the contents of the file with the specified
 * name.  The "error" message indicates that the specified
 * file does not exist on the server.  (The server can also
 * respond with the message "unknown command" if the command
 * it reads is not one of the two possible legal commands.)
 * 
 * The client program works with command-line arguments.
 * The first argument must be the name or IP address of the
 * computer where the server is running.  If that is the
 * only argument on the command line, then the client
 * gets the list of files from the server and displays
 * it on standard output.  If there are two parameters,
 * the second parameter is interpreted as the name of a
 * file to be downloaded.  A copy of the file is saved
 * as a local file of the same name, unless a file of
 * the same name already exists.  If there are three
 * arguments, the second is the name of the file to be
 * downloaded and the third is the name under which the
 * local copy of the file is to be saved.  This will
 * work even if a file of the same name already exists.
 */
public class FileClient {

   static final int LISTENING_PORT = 8000;

   public static void main(String[] args) {
   
	  String computer;		  // Name or IP address of server.
	  Socket connection;		// Socket for communicating with that computer.
	  PrintWriter outgoing;	 // Stream for sending a command to the server.
	  BufferedReader incoming;  // Stream for reading data from the connection.
	  String command;		   // Command to send to the server.
	  

	  /* Check that the number of command-line arguments is legal.
		 If not, print a usage message and end. */
	  
	  if (args.length == 0 || args.length > 3) {
		 System.out.println("Usage:  java FileClient <server>");
		 System.out.println("	or  java FileClient <server> <file>");
		 System.out.println(
			   "	or  java FileClient <server> <file> <local-file>");
		 return;
	  }
	  
	  /* Get the server name and the message to send to the server. */
	  
	  computer = args[0];
	  
	  if (args.length == 1)
		 command = "index";
	  else
		 command = "get " + args[1];
	  
	  /* Make the connection and open streams for communication.
		 Send the command to the server.  If something fails
		 during this process, print an error message and end. */
	  
	  try {
		 connection = new Socket( computer, LISTENING_PORT );
		 incoming = new BufferedReader( 
						   new InputStreamReader(connection.getInputStream()) );
		 outgoing = new PrintWriter( connection.getOutputStream() );
		 outgoing.println(command);
		 outgoing.flush();
	  }
	  catch (Exception e) {
		 System.out.println(
			  "Can't make connection to server at \"" + args[0] + "\".");
		 System.out.println("Error:  " + e);
		 return;
	  }
	  
	  /* Read and process the server's response to the command. */
	  
	  try {
		 if (args.length == 1) {
			   // The command was "index".  Read and display lines
			   // from the server until the end-of-stream is reached.
			System.out.println("File list from server:");
			while (true) {
			   String line = incoming.readLine();
			   if (line == null)
				   break;
			   System.out.println("   " + line);
			}
		 }
		 else {
			   // The command was "get <file-name>".  Read the server's
			   // response message.  If the message is "ok", get the file.
			String message = incoming.readLine();
			if (! message.equals("ok")) {
			   System.out.println("File not found on server.");
			   return;
			}
			PrintWriter fileOut;  // For writing the received data to a file.
			if (args.length == 3) {
				  // Use the th/ird parameter as a file name.
			   fileOut = new PrintWriter( new FileWriter(args[2]) );
			 
			}
			else {
				  // Use the second parameter as a file name,
				  // but don't replace an existing file.
				File file = new File(args[1]);
				if (file.exists()) {
				   System.out.println("A file with that name already exists.");
				   System.out.println("To replace it, use the three-argument");
				   System.out.println("version of the command.");
				   return;
				}
				fileOut = new PrintWriter( new FileWriter(args[1]) );
			}
			while (true) {
				   // Copy lines from incoming to the file until
				   // the end of the incoming stream is encountered.
				String line = incoming.readLine();
				if (line == null)
					break;
				fileOut.println(line);
			}
			if (fileOut.checkError()) {
			   System.out.println("Some error occurred while writing the file.");
			   System.out.println("Output file might be empty or incomplete.");
			}
		 }
	  }
	  catch (Exception e) {
		 System.out.println(
				 "Sorry, an error occurred while reading data from the server.");
		 System.out.println("Error: " + e);
	  }
	  finally {
		 try {
			connection.close();
		 }
		 catch (IOException e) {
		 }
	  }
	  
   }  // end main()
   

} //end class FileClient



Finally, here is the custom class TextReader:
[code]


import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* The TextReader class provides methods for reading data expressed in human-readable
* character format. A TextReader can be used as a wrapper for any Reader or
* InputStream to enable easy character-based input.
*
* Note that all of the input methods in this class throw errors of type
* IOException. An IOException can occur whan an attempt is made to read
* data from the input source. An error can occur if an attempt is made to
* read past the end of the input source; the exception in this case is of
* type TextReader.EndOfStreamError, which is a subclass of IOException.
* An error can also occur if an attempt is made to read data of a particular
* type from the input and the next item in input is not of the correct type;
* in this case, the error is of type TextReader.BadDataException, which is
* another subclass of IOException.
*
* Once an input stream has been wrapped in a TextReader, data should only be
* read from the stream using the wrapper. This is because the TextReader reads
* and buffers some data internally, and any data that has been buffered is not
* available for reading except through the TextReader.
*/
public class TextReader {


/**
* The value returned by the peek() method when the input is at end-of-stream.
* (The value of this constant is (char)0xFFFF.)
*/
public final char EOF = (char)0xFFFF;

/**
* The value returned by the peek() method when the input is at end-of-line.
* The value of this constant is the character '\n'.
*/
public final char EOLN = '\n';

/**
* Represents the error of trying to read past the end of the input source
* of the TextReader. Users of the class could catch this exception to
* detect end-of-stream. This is a subclass of IOException, so catching
* IOException will also catch end-of-stream errors.
*/
public static class EndOfStreamException extends IOException {
public EndOfStreamException() {
super("Attempt to read past end-of-stream.");
}
}

/**
* Represents the error that occurs whan an attempt is made to read some type
* of data, and the next item in the stream is not of the correct type.
* This is a subclass of IOException, so catching
* IOException will also catch BadDataException.
*/
public static class BadDataException extends IOException {
public BadDataException(String errorMessage) {
super(errorMessage);
}
}



// ***************************** Constructors and closing *********************


/**
* Create a TextReader that will take its input from a specified Reader.
* @s the non-null Reader from which the TextReader will read.
* @throws NullPointerException if s is null.
*/
public TextReader(Reader s) {
if ( s == null )
throw new NullPointerException("Can't create a TextReader for a null stream.");
if (s instanceof BufferedReader)
in = (BufferedReader)s;
else
in = new BufferedReader(s);
}


/**
* Create a TextReader that will take its input from a specified InputStream.
* (Internally, the InputStream is wrapped in a Reader of type InputStreamReader.)
* @s the non-null InputStream from which the TextReader will read.
* @throws NullPointerException if s is null.
*/
public TextReader(InputStream s) {
this( new InputStreamReader(s) );
}


/**
* Closes the stream that is the input source for this TextReader by
* calling its close() method. Does not throw any excpetions; if
* an excpetion occurs when the input source is closed, that exception
* is ignored.
*/
public void close() {
try {
in.close();
}
catch (IOException e) {
}
}


// *************************** Input Methods *********************************

/**
* Test whether the next character in the input source is an end-of-line. Note that
* this method does NOT skip whitespace before testing for end-of-line -- if you want to do
* that, call skipBlanks() first.
*/
public boolean eoln() throws IOException {
return peek() == '\n';
}

/**
* Test whether the next character in the input source is an end-of-file. Note that
* this method does NOT skip whitespace before testing for end-of-line -- if you want to do
* that, call skipBlanks() or skipWhitespace() first.
*/
public boolean eof() throws IOException {
return peek() == EOF;
}

/**
* Reads the next character from the input source. The character can be a whitespace
* character; compare this to the getChar() method, which skips over whitespace and returns the
* next non-whitespace character. An end-of-line is always returned as the character '\n', even
* when the actual end-of-line in the input source is something else, such as '\r' or "\r\n".
*/
public char getAnyChar() throws IOException {
return readChar();
}

/**
* Returns the next character in the input source, without actually removing that
* character from the input. The character can be a whitespace character and can be the
* end-of-file character (specfied by the constant TextIO.EOF). An end-of-line is always returned
* as the character '\n', even when the actual end-of-line in the input source is something else,
* such as '\r' or "\r\n".
*/
public char peek() throws IOException {
return lookChar();
}

/**
* Skips over any whitespace characters, except for end-of-lines. After this method is called,
* the next input character is either an end-of-line, an end-of-file, or a non-whitespace character.
*/
public void skipBlanks() throws IOException {
char ch=lookChar();
while (ch != EOF && ch != '\n' && Character.isWhitespace(ch)) {
readChar();
ch = lookChar();
}
}

/**
* Skips over any whitespace characters, including for end-of-lines. After this method is called,
* the next input character is either an end-of-file or a non-whitespace character.
*/
private void skipWhitespace() throws IOException{
char ch=lookChar();
while (ch != EOF && Character.isWhitespace(ch)) {
readChar();
ch = lookChar();
}
}

/**
* Skips whitespace characters and then reads a value of type byte from input,
* discarding the rest of the current line of input (including the next end-of-line
* character, if any). An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
*/
public byte getlnByte() throws IOException{
byte x=getByte();
emptyBuffer();
return x;
}

/**
* Skips whitespace characters and then reads a value of type short from input,
* discarding the rest of the current line of input (including the next end-of-line
* character, if any). An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
*/
public short getlnShort() throws IOException {
short x=getShort();
emptyBuffer();
return x;
}

/**
* Skips whitespace characters and then reads a value of type int from input,
* discarding the rest of the current line of input (including the next end-of-line
* character, if any). An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
*/
public int getlnInt() throws IOException {
int x=getInt();
emptyBuffer();
return x;
}

/**
* Skips whitespace characters and then reads a value of type long from input,
* discarding the rest of the current line of input (including the next end-of-line
* character, if any). An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
*/
public long getlnLong() throws IOException {
long x=getLong();
emptyBuffer();
return x;
}

/**
* Skips whitespace characters and then reads a value of type float from input,
* discarding the rest of the current line of input (including the next end-of-line
* character, if any). An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
*/
public float getlnFloat() throws IOException {
float x=getFloat();
emptyBuffer();
return x;
}

/**
* Skips whitespace characters and then reads a value of type double from input,
* discarding the rest of the current line of input (including the next end-of-line
* character, if any). An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
*/
public double getlnDouble() throws IOException {
double x=getDouble();
emptyBuffer();
return x;
}

/**
* Skips whitespace characters and then reads a value of type char from input,
* discarding the rest of the current line of input (including the next end-of-line
* character, if any). An error occurs if an attempt is made to read past end-of-file
* or if an IOException is thrown when an attempt is made to read data from the
* input source.
*/
public char getlnChar() throws IOException {
char x=getChar();
emptyBuffer();
return x;
}

/**
* Skips whitespace characters and then reads a value of type double from input,
* discarding the rest of the current line of input (including the next end-of-line
* character, if any). An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
* <p>Legal inputs for a boolean input are: true, t, yes, y, 1, false, f, no, n,
* and 0; letters can be either upper case or lower case. One "word" of input is read,
* using the getWord() method, and it must be one of these; note that the "word"
* must be terminated by a whitespace character (or end-of-file).
*/
public boolean getlnBoolean() throws IOException {
boolean x=getBoolean();
emptyBuffer();
return x;
}

/**
* Skips whitespace characters and then reads one "word" from input, discarding the rest of
* the current line of input (including the next end-of-line character, if any). A word is
* defined as a sequence of non-whitespace characters (not just letters!). An error occurs
* if an attempt is made to read past end-of-file or if an IOException is thrown when an
* attempt is made to read data from the input source.
*/
public String getlnWord() throws IOException {
String x=getWord();
emptyBuffer();
return x;
}

/**
* This is identical to getln().
*/
public String getlnString() throws IOException {
return getln();
}

/**
* Reads all the charcters from the input source, up to the next end-of-line. The end-of-line
* is read but is not included in the return value. Any other whitespace characters on the line
* are retained, even if they occur at the start of input. The return value will be an empty
* string if there are no characters before the end-of-line. An error occurs if an attempt is
* made to read past end-of-file or if an IOException is thrown when an attempt is made to
* read data from the input source.
*/
public String getln() throws IOException {
StringBuffer s = new StringBuffer(100);
char ch = readChar();
while (ch != '\n') {
s.append(ch);
ch = readChar();
}
return s.toString();
}

/**
* Skips whitespace characters and then reads a value of type byte from input.
* Any characters that remain on the line are saved for subsequent input operations.
* An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
*/
public byte getByte() throws IOException {
return (byte)readInteger(-128L,127L);
}

/**
* Skips whitespace characters and then reads a value of type short from input.
* Any characters that remain on the line are saved for subsequent input operations.
* An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
*/
public short getShort() throws IOException{
return (short)readInteger(-32768L,32767L);
}

/**
* Skips whitespace characters and then reads a value of type int from input.
* Any characters that remain on the line are saved for subsequent input operations.
* An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
*/
public int getInt() throws IOException {
return (int)readInteger((long)Integer.MIN_VALUE, (long)Integer.MAX_VALUE);
}

/**
* Skips whitespace characters and then reads a value of type long from input.
* Any characters that remain on the line are saved for subsequent input operations.
* An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
*/
public long getLong() throws IOException {
return readInteger(Long.MIN_VALUE, Long.MAX_VALUE);
}

/**
* Skips whitespace characters and then reads a value of type char from input.
* Any characters that remain on the line are saved for subsequent input operations.
* An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
*/
public char getChar() throws IOException {
skipWhitespace();
return readChar();
}

/**
* Skips whitespace characters and then reads a value of type float from input.
* Any characters that remain on the line are saved for subsequent input operations.
* An error occurs if an attempt is made to read past end-of-file,
* or if an IOException is thrown when an attempt is made to read data from the
* input source, or if a value of the correct type is not found in the input.
*/
public float getFloat() throws IOException {
float x = 0.0F;
while (true) {
String str = readRealString();
if (str == null) {
errorMessage("Floating point number not found.",
"Real number in the range " + (-Float.MAX_VALUE) + " to " + Float.MAX_VALUE);
}
else {
try {
x = Float.parseFloat(str);
}

This post has been edited by mdhol: 04 November 2009 - 10:22 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Java NetWorking: Simple Server and Client program

#2 mdhol  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 03-November 09

Re: Java NetWorking: Simple Server and Client program

Posted 04 November 2009 - 12:31 PM

Hi,

Here is the block of code that cataches the error i am asking about and prints the message:

 catch (Exception e) {
		 System.out.println(
				 "Sorry, an error occurred while reading data from the server.");
		 System.out.println("Error: " + e);
}



HELP!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1