Is it necessary to close Scanner when there is no stream underlying?

java, java.util.scanner

Solution

First we make our habits; then our habits make us.

I'd say close the stream, because ingraining a habit like closing resources in `finally` blocks make sense.

Problem

Directly from this Scanner API: ``` String input = "1 fish 2 fish red fish blue fish"; Scanner s = new Scanner(input).useDelimiter("\\s*fish\\s*"); System.out.println(s.nextInt()); System.out.println(s.nextInt()); System.out.println(s.next()); System.out.println(s.next()); s.close(); ```

Original source