I am trying to read in a command and a name. For example "name:" + "username" and I want to add the username to an arraylist. I am trying to split the input, so that I have a name variable and a username variable as shown below:
public void run() {
String line;
try {
while(true) {
line = input.readLine();
String[] temp;
temp = line.split(":");
//checks different input from the client
//checks to see if the client wants to terminate their connection
//removes the client's name from the list
if("name:".equals(temp[0])) {
users.add(temp[1]);
output.println("OK");
}
else {
broadcast(name,line); // method in outer class - send messages to all
}
} // end of while
} catch(Exception e) {
System.out.println(e.getMessage());
}
} // end of run()