客户端登陆后,用户成员列表一直为空。以下是服务端与客户端的源代码。望大师能多多指教。补充下,客户端运行后,会抛出异常如下:Exception in thread "Thread-2" java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(Unknown Source)
at chatFrame.run(Chat.java:199)
at java.lang.Thread.run(Unknown Source)
我是菜鸟,整了半天,也不知道该怎么解决,特来此请教大师。望能高抬贵手,给出解决之法……
服务器端源代码:
import java.io.*;
import java.net.*;
import java.util.*;
public class Server extends ServerSocket
{
static final int SERVER_PORT=10000;
Vector<Object> vector1=new Vector<Object>();
Vector<Object> vector2=new Vector<Object>();
public Server() throws IOException
{
super(SERVER_PORT);
try{
while(true)
{
System.out.println("等待客户连接……");
Socket socket=accept();
new CreateServerThread(socket,vector1,vector2);
}
}
catch(IOException e){System.out.println("客户连接错误");}
finally
{
close();
}
}
public static void main(String[] args) throws IOException
{
new Server();
}
}
class CreateServerThread extends Thread
{
Socket socket;
DataInputStream in;
DataOutputStream out;
Vector<Object> vector1;
Vector<Object> vector2;
public boolean bool=false;
String revStr=null;
String string=null;
int userID;
String str=null;
Enumeration enu;
public CreateServerThread(Socket s,Vector<Object> vec1,Vector<Object> vec2)throws IOException
{
socket=s;
vector1=vec1;
vector2=vec2;
out=new DataOutputStream(socket.getOutputStream());
in=new DataInputStream(socket.getInputStream());
start();
}
public void run()
{
StringTokenizer st;
StringTokenizer stc;