I would like to extract The Name and Age from The Text file from it. Can someone please provide me some help?
The text content :
fhsdgjfsdk;snfd fsd ;lknf;ksld sldkfj lk
Name: Max Pain
Age: 99 Years
and they df;ml dk fdj,nbfdlkn ......
Code:
package myclass;
import java.io.*;
public class ReadFromFile2 {
public static void main(String[] args)throws Exception {
File file = new File("C:\\Users\\Ss\\Desktop\\s.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
while ((st = br.readLine()) != null)
System.out.println(st.substring(st.lastIndexOf("Name:")));
// System.out.println(st);
}
}