I have this piece of code
private String getMessage(BufferedReader in) throws IOException{
StringBuilder sb = new StringBuilder();
while(true){
char pom = (char) in.read();
sb.append(pom);
if (sb.toString().contains("\r\n")) {
String result = sb.toString();
result = result.replace("\r\n", "");
return result;
}
}
}
I want user to write on console some message. And when he writes '\r\n' console should end its input. But this doesn't work... Don't you have some tips what could be the problem?
And in aditional, i don't want to use in.close(); coz i will need this input later.