Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File Read Help???  RSS feed

 
Murali Obla
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,
I am writing to a file and reading from the file using file streams.Here I want to read the recently appended lines from the file!!!.
For example,
Initially I have 10 lines in file.I am reading that.Now I am adding 5 lines after that.Here I have to read those 5 lines which are recently appended and not 15 lines.How can I do that...
Can any one please give me a sample code for this
TIA,
Murali
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds like a school assignment. What do you have so far?
An important question: Must the program resume from its previous state each time it runs (as if it had never stopped), or can it simply start from scratch (as if the file has never been modified)?
David Weitzman
[ May 06, 2002: Message edited by: David Weitzman ]
[ May 06, 2002: Message edited by: David Weitzman ]
 
Murali Obla
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,
Thanks for ur reply.Though it sounds like a school assignmrnt,I am really struggling to do this.Since I am new to I/O(learning now).So pls bare with my questions.

I think the program would start from its previous state each time.
What I exactly need is that some kind of bookmark inside the file and search for that mark and read from there!!.How will I do that?.
Thanks in Advance,
Murali
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adding a bookmark to the file would be actively inserting extra data into the file. If you don't mind doing that, it would work.
My initial response was a bit different. If you store the number of lines that have been read already in a persistant location (i.e. another file), you can simply skip that many lines without further analysis.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!