• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

mark(i) and reset()  RSS feed

 
Greenhorn
Posts: 17
  • 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.
 
Ranch Hand
Posts: 116
  • 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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!