How can I check whether input is available from a `Scanner` without risking blocking?

Consider the method below, for example. In each loop iteration it should accept user input if there is any, but proceed without input if none has been entered. Instead, `reader.nextLine()` waits for the user to input a a line before proceeding.

```
public void creatureCombate() {

    while (true) {
        Scanner reader = new Scanner(System.in);
        String userInput = reader.nextLine();

        wait(1);
        System.out.println("Wolf attacks");

        if(userInput.equals("hit")){
            System.out.println("hit wolf");
        } else{
            System.out.println("Tries again");  
        }
    }
}

```