I am trying to make an IRC bot for my channel. I would like the bot to be able to take commands from the console. In an attempt to make the main loop wait for the user to input something I added the loop:
while(!userInput.hasNext());
this did not seem to work. I have heard of BufferedReader but I have never used it and am not sure if this would be able to solve my problem.
while(true) {
System.out.println("Ready for a new command sir.");
Scanner userInput = new Scanner(System.in);
while(!userInput.hasNext());
String input = "";
if (userInput.hasNext()) input = userInput.nextLine();
System.out.println("input is '" + input + "'");
if (!input.equals("")) {
//main code
}
userInput.close();
Thread.sleep(1000);
}