• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mark(i) and reset()

 
Nazmul Bhuiyan
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been searching for the topic mark and reset and found no exact answer for this. One solution was to recreate the reader. But what about If I don't want to create a new object?
I just copied this from previously posted by Paul Keohan, posted November 11, 2002
Can any one let us know how to use mark and reset please?
When using the readLine() method of BufferedReader to trace through the lines of a file, how can I 'reset' the file to go back to the beginning? The reset() method requires a 'mark' which is set up with a mark(int readAheadLimit) method. All I want is to return to the start of my file without having to create a new object.
 
Gayathri Prasad
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The one strategy which strikes me is..
After you open the InpustStream.. first call the mark method with the size of the InputStream as the readLimit to the mark method. You can calculate the # of bytes by using the available() method. And as ur marking the InputStream before you read the data and after you open the InputStream, when ever u call the reset() method, it would reposition the stream to the point where the mark() method was last called. In our case we called it at the beginning of the InputStream thus invariably the Stream moves to the starting point of the InputStream.
ATB,
Gaya3
--------------------------------------------------
Beginning is half done
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic