Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading files from the end

 
Fernando Dominguez
Ranch Hand
Posts: 108
Debian Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Hello,

I have to read 2 fields which are located at the end of a text file.

Is there any way to do that without reading the complete file?

Is it possible to start reading a file from the end and finish on top?

Many thanks.

<field>
<field>
<.....>
<.....>
<field to read>
<filed to read>
 
Joe Ess
Bartender
Posts: 9319
10
Linux Mac OS X Windows
 
Fernando Dominguez
Ranch Hand
Posts: 108
Debian Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that RandomAccessFile would be usefull if I knew the size or structure of the fileds,

but I dont know anything about the fields except their names.

My Idea was to begin reading at botton of the file and climb over the file because I these fields are always at the botton.

How do you would use RandonAccess field class in that case?

Thanks
 
Joe Ess
Bartender
Posts: 9319
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get the length of the file, set the file pointer to the end of the file, read a byte, back up one, read a byte, and so on.
 
Fernando Dominguez
Ranch Hand
Posts: 108
Debian Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I´m going to try it...

Thans.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic