Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

aw1231

  • 4 years ago

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

  • This Question is Closed
  1. jsba928
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 2

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

  2. aw1231
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  3. jsba928
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 2

    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.

  4. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy