Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

I/O Chaining

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi all,
How to determine which Classes can be chained in the I/O. Does it all depends on the constructors of each individual class.
What I know.
OutputStream, InputStream,Reader,Writer,FilterReader,FilterWriter
are abstract and cannot be instantiated.
Low-Level Streams
InputStreams - FileInputStream,ByteArrayInputStream,PipedInputStream
OutputStreams -
FileOutputStream,ByteArrayOutputStream,PipedOutputStream
Reader- FIleREader,CharArrayReader,PipedReader,StringReader
Writer- FileWriter,CharArrayWriter,PipedWriter,StringWriter
High-Level Streams
InputStream,FilterInputStream,BufferedInputStream,DataInputStream,PushbackInputStream, SequenceInputStream,ObjectInputStream
OutputStream,FilterOutputStream,BufferedOutputStream,DataOutputStream,PrintStream,ObjectOutputStream
Reader,FilterReader,PushbackReader,LineNumberReader,BufferedReader,InputStreamReader,
Writer,FilterWriter,,BufferedWriter,PrintWriter,OutputStreamWriter.
------------------------------------------------------------
But I am in a confusion to which among these Low-Level Stream and High-Level Streams are to be chained and which shouldn't be chained. I know that Readers and Writers are different and Streams are different. I know that Readers and Writers are for Characters and Streams are used for Bytes.
I am writing all this information so that people just don't point me to API.and try to come to my rescue. Please.....
I know the Hierarchy. Does this one completely depend on the constructors. Which one is legal and which one isn't.
thanks in adv.
Babudaan!

 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can chain in/output streams with others using subclasses of FilterIn/OutputStream...
Subclasses of FilterOutputStreams are
BufferedOutputStream, CheckedOutputStream, CipherOutputStream, DataOutputStream, DeflaterOutputStream, DigestOutputStream, PrintStream
Subclasses of FilterInputStreams are
BufferedInputStream, CheckedInputStream, CipherInputStream, DataInputStream, DigestInputStream, InflaterInputStream, LineNumberInputStream, ProgressMonitorInputStream, PushbackInputStream
For instance you can chain streams as follows:

What you have here is a primitive-writable, portable and buffered stream to a file. You achieve stream chaining by using Filter*Stream, i.e. each Filter may add its 2 cents to the reading/writing process. A CipherOutputStream automatically encrypt what is written to it, a ZipOutputStream un/compresses the given contents, etc...
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
[This message has been edited by Valentin Crettaz (edited November 13, 2001).]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic