I was making a chat program in Java (Java Socket) and I was thinking about making build-in-commands! For and example; you write "date" and it will show the date! Here I have maked one but it dosen't work. It shows only the "else" satement!
streamChat = (String) inputdata.readObject(); //Reading the object.. and storing it in a variable...
if(streamChat.equals("date")){
Date date = new Date();
showMess("\n " + date);
}else{
showMess("\n " + streamChat);
}
The answer is simple... I see that streamChat = (String) inputdata.readObject();
is INPUT from the client. So only if the client send "date" you will get the date. Remove if statement to another place in the output area.