Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

First line of file  RSS feed

 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am reading form a .data file but it only seems to be reading the first line of the code when I in more than the next code in the loop




It works well in the example but if I in in the loop something like



it only reads the first line
Any idea?

Thanks


 
Tony Docherty
Bartender
Posts: 3270
82
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you read the AvailableDoesntDoWhatYouThinkItDoes FAQ
 
Rob Spoor
Sheriff
Posts: 21114
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, you can't call dis.readLine() twice while still expecting the same line to be returned. Any method that reads part of a file (or InputStream or Reader) moves forward in the file (or InputStream or Reader). Anything that was just read won't be re-read again unless you use the mark / reset method pair.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!