why is scanner not working
<p>I am trying to read a input of this format</p>

<pre><code>4 4
* . . .
. . . .
. * . .
. . . .
4 4
* * . .
. . . .
. . . .
. . * .
</code></pre>

<p>I am able to read the first two numbers, when I try to read the symbols I get an exception. I can use BufferedReader to read each line and parse the input but why can't I do this with scanner?</p>

<p>This is my code</p>

<pre><code>        public static void main(String[] args) {
                Scanner in = new Scanner(System.in);
                while (in.hasNextLine()) {
                    Scanner s = new Scanner(in.nextLine());
                    if (!s.hasNextLine())
                        break;

                    int x = s.nextInt(); // 4
                    int y = s.nextInt(); // 4
                    for (int i = 0; i &lt;= x - 1; i++) {
                        for (int j = 0; j &lt;= y - 1; j++) {
                            System.out.println(s.hasNext()); // false
                            String symbol = s.next(); //NoSuchElementException WHY?
                        }
                    }
                }
            }
        }
</code></pre>
