As title, I want it to exit the loop when I entered a specific keyword.
try {
buf = br.readLine();
while (buf != "doh") {
buf = br.readLine();
}
}
Two questions:
When I enter
doh
from my command prompt, it doesn't exit the loop.If I put
"buf != null"
it works only if I press Ctrl+Z. If I enter nothing (just press enter key) it doesn't exit the loop.