import java.util.Scanner;
import java.io.*;
public class program1 {
Scanner filescan = null;
public program1(){
try {
filescan = new Scanner (new File("t.txt"));
} catch (FileNotFoundException fe){
fe.printStackTrace();
}
}
public static void main(String[] args)throws IOException {
printFile();
}
public static void printFile()throws IOException {
int num;
while(filescan.hasNextInt()){
num= filescan.nextInt();
System.out.print(num+" ");
}
}
}
I've been battling with tryin to figure out how to use the scanner object "filescan" througout all my functions. can someone please direct on how to do this. im sure im not too far from getting it right.
thanks
when i attempt top use "filesan" in the print file method i get ------->
Cannot make a static reference to the non-static field filescan
but i need this method to be static so that i may call it in the main?
not sure on what needs to be done at this point