Ask your own question, for FREE!
Computer Science 6 Online
OpenStudy (aw1231):

How do I use java to read a simple offline html file?

OpenStudy (anonymous):

How do you want to read it? I have some file I/O demos if you want to see them....

OpenStudy (aw1231):

I want it to scan for a certain phrase with a number and output that number.

OpenStudy (anonymous):

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.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!