Đọc File bằng Scanner
public void docFile(){
try{
File f = new File("D:\\sinhvien.txt"); // duong dan tuyet doi
if(f.exists()){
Scanner read = new Scanner(f);
// doc du lieu trong file nhu doc tu ban phim
while(read.hasNext()){
Scanner line = new Scanner(read.nextLine());
// đọc dữ liệu cho từng trường trên 1 dòng
}
}
}else System.out.println(" Khong ton tai file");
}catch(Exception e){
}
}