This is my file directory
I am trying to open admin.dat
for reading but dont understand why am i unable to open the file and the FileNotFound
exception is always thrown
Code:
public void readfile(){
try{
Scanner filereader = new Scanner(new File("admin.dat"));
String data;
while(filereader.hasNextLine()){
data = filereader.nextLine();
System.out.println(data);
}
}
catch (FileNotFoundException e){
System.out.println("File not found");
}
catch (IOException e){
System.out.println("Error while reading file");
}
}