• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Chaining readers

 
Stan Lederer
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been playing with reading a gzip'd file.

This works fine:

Two questions:

1. Is the approach I pieced together from various websites the best/most elegant way to read text from a gzip'd file?

2. There are two streams and a reader. Which of the streams/reader should I close when I'm done reading the file. All of them?

Thanks very much.
 
Matthew Brown
Bartender
Posts: 4567
8
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. I think you've got one more reader than you need there. You should be able to pass fstream straight into the InputStreamReader - I don't see any need to introduce a DataInputStream. Other than that, it looks fine.

2. Close the outer one (your BufferedReader) and that will cascade down - it will close all of them.
 
Stan Lederer
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:1. I think you've got one more reader than you need there. You should be able to pass fstream straight into the InputStreamReader - I don't see any need to introduce a DataInputStream. Other than that, it looks fine.

2. Close the outer one (your BufferedReader) and that will cascade down - it will close all of them.

Excellent. Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic