• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

reading basic text from website with bufferedreader

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm writing a program to get text data from a website. I could get it to work, but I'm confused about why it works how it does. This question is about why it does one thing vs another...
The site I'm reading from looks like this:


....

Here is part of my code


I am trying to get the index of E in TEXT. If i run the program above it returns the index of E in <PRE>. Why, if i uncomment reader.readLine will it still return the index of <PRE>? It confuses me because if I uncomment next = reader.readLine() and print out next, the reader.readLine() will advance to the next line, but apparently doesnt when using indexOf.

Hope that was clear, any help is appreciated.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

k woww wrote:Why, if i uncomment reader.readLine will it still return the index of <PRE>? It confuses me because if I uncomment next = reader.readLine() and print out next, the reader.readLine() will advance to the next line, but apparently doesnt when using indexOf.



Calling "reader.readLine()" by itself advances to the next line and throws that line away. It doesn't change the value of the "line" variable, which therefore still contains <PRE>. Calling "next = reader.readLine()" advances to the next line and assigns that line to the "next" variable.
 
Kevin Myer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahh, thank you!
 
Look! I laid an egg! Why does it smell like that? Tiny ad, does this smell weird to you?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic