• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confused by Sun I/O tutorial

 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic