import java.util.Scanner;
import java.io.*;
public class program1 {
static 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{
while(filescan.hasNextInt())
System.out.println(filescan.nextInt());
}
}
I have tried this and i get -------->
Exception in thread "main" java.lang.NullPointerException
at program1.printFile(program1.java:23)
at program1.main(program1.java:16)