1

I am reading a huge txt file inside zip.

GZIPInputStream fstream = new GZIPInputStream(new FileInputStream(zipfile));
BufferedReader breader = new BufferedReader(new InputStreamReader(fstream));

I need to read last n lines, of the file.

Is it possible to do that without readline until eof?

Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93
kenny
  • 2,000
  • 6
  • 28
  • 38
  • it is not possible to read stream/dictionary compressed "file", unless there is something like Z_FULL_FLUSH (and dumping the dictionary) – bestsss Nov 04 '11 at 19:43

1 Answers1

4

Is it possible to do that without readline until eof?

No and well due to the following two reasons:

  1. You cannot read a stream backwards.
  2. You cannot un(g)zip backwards.

Just read the entire stream wherein you ignore the lines which you aren't interested in.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • technically it's possible to read past Z_FULL_FLUSH mark (provided anyone would bother to place) – bestsss Nov 04 '11 at 19:43