问题在closeConnection 这个函数中,抛出了一个NullPointerException,想了半天也不知道怎么解决帮忙看看吧import java.io.EOFException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import java.util.concurrent.*;public class Server extends JFrame 
{
   private int counter = 1; // counter of number of connections
   private final int size = 100;
   private int area;
   private int width = 0;
   private int longth = 0;  
   private Multi multi;
   private JTextArea displayArea; 
   private ExecutorService executor;
  
   public Server()
   {
      super( "Server" );
      multi = new Multi();
      executor = Executors.newFixedThreadPool(10);
      executor.execute(multi);
      displayArea = new JTextArea(); 
      add( new JScrollPane( displayArea ), BorderLayout.CENTER );      setSize( 300, 150 ); 
      setVisible( true ); 
   } public class Multi implements Runnable
 {
   private ObjectOutputStream output; // output stream to client
   private ObjectInputStream input; // input stream from client
   private ServerSocket server; // server socket
   private Socket connection; // connection to client
   // set up and run server 
   public void run()
   {
      try 
      {
         server = new ServerSocket( 12345, 100 );          while ( true ) 
         {
            try 
            {
               waitForConnection(); 
               getStreams(); 
               processConnection(); 
            } 
            catch ( EOFException eofException ) 
            {
               displayArea.append( "\nServer terminated connection" );
            } 
            finally 
            {
               closeConnection(); //  close connection
               ++counter;
            } 
         } 
      } 
      catch ( IOException ioException ) 
      {
         ioException.printStackTrace();
      }
   }    // wait for connection to arrive, then display connection info
   private void waitForConnection() throws IOException
   {
      displayArea.append( "Waiting for connection\n" );
      connection = server.accept();       
      displayArea.append( "Connection " + counter + " received from: " +
         connection.getInetAddress().getHostName() );
   }    // get streams to send and receive data
   private void getStreams() throws IOException
   {
      output = new ObjectOutputStream( connection.getOutputStream() );
      output.flush();       input = new ObjectInputStream( connection.getInputStream() );      displayArea.append( "\nGot I/O streams\n" );
   }   // process connection with client
   private void processConnection() throws IOException
   {
      String message = "Connection successful";
      sendData( message );       do 
      {
         try 
         {
if(width == 0)

              width = Integer.parseInt(( String )input.readObject());
            }
            else
            {
  longth = Integer.parseInt(( String )input.readObject()); 
  area = width*longth;
  width = 0;
  longth = 0;
  if(area > size)
  {displayArea.append("\n" +area + "large");}
  if(area == size)
  {displayArea.append("\n" +area + "equal");}
  if(area < size)
  {displayArea.append("\n" + area + "small");}
}
         } // end try
         catch ( ClassNotFoundException classNotFoundException ) 
         {
            displayArea.append( "\nUnknown object type received" );
         } // end catch      } while ( !message.equals( "CLIENT>>> TERMINATE" ) );
   } // end method processConnection   // close streams and socket
   private void closeConnection() 
   {
      displayArea.append("\nTerminating connection\n" );      try 
      {
         output.close(); 
         input.close();
         connection.close(); 
      } 
      catch ( IOException ioException ) 
      {
         ioException.printStackTrace();
      } 
   }    // send message to client
   private void sendData( String message )
   {
      try 
      {
         output.writeObject( "SERVER>>> " + message );
         output.flush();
         displayArea.append( "\nSERVER>>> " + message );
      } 
      catch ( IOException ioException ) 
      {
         displayArea.append("\nError writing object" );
      } 
   }
  }