aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Chained Streams Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Chained Streams" Watch "Chained Streams" New topic
Author

Chained Streams

kumar bangali
Greenhorn

Joined: Dec 01, 2001
Posts: 27
Hi
Please consider the following
FileInputStream fis = new FileInputStream("read_this");
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream dis = new DataInputStream(bis);
Is this piece of code correct? I ask because both buffered input stream and data input stream are high level streams. Is it not required to chain a low level stream to a high level stream? How can two high level streams be chained to one another?


Bos Indicus
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Yes this is correct.
There is no real limit on how many FilteredStreams you can chain together. Each FilteredStream provides some additional behaviour above and beyond what its nested Stream provides.
Rob


Rob
SCJP 1.4
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1865
Hi,
this code is valid as Rob pointed out. this code can help if we have formatted input about which we know priorly and it is huge/large in content. so we want buffering while taking input.
so we can chain buffered stream to datainput stream.
regards
maulin.


1. Have fun @ http://faq.javaranch.com/java/JavaRaq
2. Looking for simple infix2postfix conversion and postfix evaluation package? Click here
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Chained Streams
 
Similar Threads
stream constructors
how to read line by line and pass each line value to a method
Reading Data from a file and extracting the data
Input/Output Question...
DataOutputStream