import java.util.Scanner; public class ScannerExample { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { String input = scanner.next(); System.out.println("You entered: " + input); } scanner.close(); } }In this code example, we create a Scanner object and use a while loop to iterate through the input stream until there are no more tokens. Each token is stored in a String variable called "input", which is then printed to the console. The package library for the Scanner class is java.util, which is part of the Java Standard Library.