It works (not as I wanted, the loop breaks if there is any 'x' present in the text like 'asdx') if I set condition as c=='x' but not if I put it as s=="x" (so loop breaks only if I type a single x only)
public static void main(String[] args) throws IOException {
InputStreamReader i = new InputStreamReader(System.in);
String z = "";
boolean bool=true;
while (bool==true) {
int x = i.read();
char c = (char) x;
String s = Character.toString(c);
z += s;
if (s=="x") {
bool=false;
}
}
out.println(z);
}