• Post Reply Bookmark Topic Watch Topic
  • New Topic

Confused by Sun I/O tutorial  RSS feed

 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was reading the Sun I/O tutorial trail. When I got to the page called Working with Filter Streams I cam across the following quote with corresponding code:

Using Filter Streams

To use a filter input or output stream, attach the filter stream to another input or output stream when you create it. For example, you can attach a filter stream to the standard input stream, as in the following code:

Note that the readLine method has been deprecated in the DataInputStream; therefore we've wrapped it in a BufferedReader.


Am I missing something here. Neither InputStreamReader nor BufferedReader extend FilterInputStream. Did they mean to write:

or am I totally missing something?
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think there may be confusion between the term filter input stream and FilterInputStream. I don't think they meant to imply anything about the class. However, there is a class called BufferedInputStream which is a subclass of FilterInputStream. I think they meant to not use the DataInputStream class because it's readLine() method is deprecated.
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Lynn:
I think there may be confusion between the term filter input stream and FilterInputStream. I don't think they meant to imply anything about the class. However, there is a class called BufferedInputStream which is a subclass of FilterInputStream. I think they meant to not use the DataInputStream class because it's readLine() method is deprecated.


I don't think so. Here is the sentence that immediately precedes the quote from my previous post.

This section shows you how to use filter streams by presenting an example that uses a DataInputStream and a DataOutputStream. This section also covers how to subclass FilterInputStream and FilterOutputStream to create your own filter streams.
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Further this sentence that immediately follows the code seems to imply that DataInputStream was used in the code example.

Note that the readLine method has been deprecated in the DataInputStream; therefore we've wrapped it in a BufferedReader.

[Note: emphasis mine]

I guess in the long run it really doesn't matter though. But it confused me for a little while.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually when they said it, they referred to the InputStreamReader. In previous versions of the JDK, you would have used DataInputStream. But since it's readLine() method is deprecated, they wrapped the InputStreamReader in a BufferedReader.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!