Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy it returns null pointer exception (server side )
    primarykey
    data
    text
    <p>this is my server class which let the clients to chat with each other but it will return nullpointer exception for this line: <code>while (!(line = in.readLine()).equalsIgnoreCase("/quit"))</code> would you please help me?thanks.</p> <p>my ChatHandler class:</p> <pre><code> final static Vector handlers = new Vector(10); private Socket socket; private BufferedReader in; private PrintWriter out; public ChatHandler(Socket socket) throws IOException { this.socket = socket; in = new BufferedReader( new InputStreamReader(socket.getInputStream())); out = new PrintWriter( new OutputStreamWriter(socket.getOutputStream())); } @Override public void run() { String line; synchronized (handlers) { handlers.addElement(this); // add() not found in Vector class } try { while (!(line = in.readLine()).equalsIgnoreCase("/quit")) { for (int i = 0; i &lt; handlers.size(); i++) { synchronized (handlers) { ChatHandler handler = (ChatHandler) handlers.elementAt(i); handler.out.println(line + "\r"); handler.out.flush(); } } } } catch (IOException ioe) { ioe.printStackTrace(); } finally { try { in.close(); out.close(); socket.close(); } catch (IOException e) { e.printStackTrace(); } finally { synchronized (handlers) { handlers.removeElement(this); } } } } </code></pre> <p>a part of client class:</p> <pre><code> String teXt = MainClient.getText(); os.println(teXt); os.flush(); try { String line = is.readLine(); setFromServertext("Text recieved:"+line+"\n"); is.close(); is.close(); c.close(); } catch (IOException ex) { Logger.getLogger(MainClient.class.getName()).log(Level.SEVERE, null, ex); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload