• Post Reply Bookmark Topic Watch Topic
  • New Topic

reading basic text from website with bufferedreader  RSS feed

 
Kevin Myer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Ahh, thank you!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!