I created the class Server
! However, an exception of type java.lang.NullPointerException
is thrown! Could anyone help me with this problem?
The class is as follows:
public class Server {
public static final int SERVERPORT = 8888;
public static void main(String[] args) throws IOException {
System.out.println("Starting echo server...");
ServerSocket ss = new ServerSocket(SERVERPORT);
boolean condition = true;
while (condition)
{
Socket s = ss.accept();
try
{
InputStream is = s.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String msg = br.readLine();
boolean condition1 = true;
while (condition1) {
System.out.println(msg);
msg = br.readLine();
if(msg.equals("quit")){
condition1=false;
}
}
if(msg.equals("quit")){
condition=false;
}
}
catch (IOException ioe)
{
System.err.println("I/O error: " + ioe.getMessage());
}
finally
{
try
{
s.close();
}
catch (IOException ioe)
{
assert false;
}
}
}
}
}