How do I use java to read a simple offline html file?
How do you want to read it? I have some file I/O demos if you want to see them....
I want it to scan for a certain phrase with a number and output that number.
In Java you can connect an instance of Scanner to an instance of FileInputStream and pass in the file name or path. Then you can use the nextLine() method to grab a line of text as a String from your HTML file. Example lines: import java.util.* ; import java.io.* ; Scanner inputStream = new Scanner(new FileInputStream("HTMLfilename.html")); while(inputStream.hasNextLine()) { String theLine = inputStream.nextLine(); // do your checks to see if your string has the phrase you want here } inputStream.close(); I included an example File I/O program from one of my instructors below for you to run. Good luck.
Join our real-time social learning platform and learn together with your friends!