I have a multi-chat server client program and I am attempting to get input from a client in a telnet putty window. The prompt:
String login = "2-Enter Username and a password:";
clientoutput.write((login).getBytes());
This is read by a BufferedReader:
BufferedReader br = new BufferedReader(new InputStreamReader(clientInput));
String inputLine;
String returnMessage;
while ((inputLine = br.readLine()) != null) {
// Split input line with space as delimiter using import jar
String[] words = StringUtils.split(inputLine);
// Ensure we don't get a null pointer
if (words != null && words.length > 0) {
String command = words[0];
if ("logoff".equalsIgnoreCase(command) || "q".equalsIgnoreCase(command) || "quit".equalsIgnoreCase(command)) {
logOff();
break;
}else
// Log user in
try {
clientLogIn(clientoutput, words);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
However the first word of user input is consistently read as
ÿû
: Eclipse console output:
User ÿû has logged in
So my question is where is this character ÿû coming from and is there a work around?
I am using WIndows 10 and Eclipse Version: 2019-03 (4.11.0) Build id: 20190314-1200
Additional info: I've tried to capture the user input and directly print to console :
if (login.contains("ÿû")) {
login = login.substring(1);
System.out.println("New login after removal of unxepected char: " + login);
} else {
System.out.println("User eneterd login : " + login);
}
Output:
User entered login : -Enter Username and a password:
User ÿû has logged in // after the first word has been taken