Read a file from the bottom
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   fixfix2_fixfix2
Posted On:   Monday, February 28, 2005 12:37 AM

Hello,


How can I read a text file from the bottom ??


I would like to writ a method which returns the five last line of the selected file ...


Can somebody help me ????

Thanks in advance ...

Fix.

Re: Read a file from the bottom

Posted By:   Christopher_Koenigsberg  
Posted On:   Wednesday, March 2, 2005 06:47 PM

Push the lines of the file (delimited by newlines) onto a stack, then pop them off.

Re: Read a file from the bottom

Posted By:   Stephen_Ostermiller  
Posted On:   Monday, February 28, 2005 04:38 PM

Open the file as a random access file. Set the file pointer to the last byte in the file. Read that byte. If the byte represents a new line, return, otherwise read previous bytes until you get to a new line.
About | Sitemap | Contact