Hi everyone!
I want to read a text file with the scanner class like this:
But it says I haven't declared my file, how do I have to declare it then?
Thanks guys!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import greenfoot.*; import java.io.File; import java.util.Scanner; public class pion extends Actor { int X, Y, timer=- 1 ; String reponse; public void act() { MouseInfo mouse = Greenfoot.getMouseInfo(); File fichier = new File( "reponse.txt" ); Scanner scan = new Scanner(fichier); reponse=scan.nextLine(); System.out.println(reponse); |