Resetting a .nextLine() Scanner

This is impossible to do.

The reason to not include it, is the wide range of input types it supports. One example is streams. These don’t store the results after they have been passed on, so they don’t support resetting.

So the elegant way is to create a new Scanner. If you give it many custom settings, create a factory method.

Leave a Comment