Jump to content

Scanner Help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Exem

Exem

    Newbie

  • Members
  • PipPip
  • 12 posts
I have this simple code:

PrintStream p = new PrintStream(new File("test.txt"));
p.println("asd a'da fd g' dsdg");
p.println("sdf asm,m gt, thmm ..m kl");

Scanner s = new Scanner(new File("test.txt"));

while (s.hasNextLine())
String m = s.nextLine();

Error: not a statement

My question is why doesn't this work. I don't see it and I feel really stupid. =(

I know its stupid code. I wrote it that way. I also realize if the code actually worked m would only store the last line in the file. However, why does it not work?

#2
Exem

Exem

    Newbie

  • Members
  • PipPip
  • 12 posts
I figured it out. =)

I was having an issue with scope.