
surch the word in the given file

Here is a java program that search a word from the text file and display the records related to it. For this, we have created a table.
Here is the student.txt:
1 A 90 2 B 30 3 C 80 4 D 99 5 E 85 6 F 25
Try the following code:
import java.io.*;
import java.util.*;
public class SearchWord{
public static void main(String[]args) throws Exception{
Scanner input=new Scanner(System.in);
System.out.print("Enter name to find details: ");
String word=input.next();
File f=new File("c:/student.txt");
BufferedReader freader = new BufferedReader(new FileReader(f));
String s;
while((s = freader.readLine()) != null) {
String[] st = s.split(" ");
String id = st[0];
String name = st[1];
String marks = st[2];
if(name.equals(word)){
System.out.println(id+" "+name+" "+marks);
}
}
}
}