Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

aw1231

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

  • 2 years ago
  • 2 years ago

  • This Question is Closed
  1. jsba928
    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 years ago
  2. aw1231
    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.

    • 2 years ago
  3. jsba928
    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.

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.