Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > BufferedInputStream vs. InputStream

Reply
Thread Tools

BufferedInputStream vs. InputStream

 
 
Andersen
Guest
Posts: n/a
 
      10-05-2005
What is the fundamental difference between BufferedInputStream and
InputStream?

 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      10-05-2005
"Andersen" <(E-Mail Removed)> wrote in message
news:43442d2a$0$13403$(E-Mail Removed) eenews.net...
> What is the fundamental difference between BufferedInputStream and
> InputStream?


A BufferedInputStream adds functionality to another input
stream-namely, the ability to buffer the input and to support the mark and
reset methods. InputStream, meanwhile, is an abstract class is the
superclass of all classes representing an input stream of bytes.

BTW, I composed this "intelligent sounding" answer by copying and
pasting the first sentence of the JavaDocs for BufferedInputStream and the
first sentence of the JavaDocs for InputStream. You should try reading more
about those two if you haven't already.

- Oliver


 
Reply With Quote
 
 
 
 
Rationem
Guest
Posts: n/a
 
      10-05-2005
The difference, as you may have guessed, is that BufferedInputStream
uses a buffer. BufferedInputStream is also almost always faster than
regular InputStream implementations because a bufferedStream does not
neet to as many asyncronous reads.

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-06-2005
On Wed, 05 Oct 2005 21:44:38 +0200, Andersen
<(E-Mail Removed)> wrote or quoted :

>What is the fundamental difference between BufferedInputStream and
>InputStream?


see http://mindprod.com/jgloss/buffer.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Steve Horsley
Guest
Posts: n/a
 
      10-06-2005
Andersen wrote:
> What is the fundamental difference between BufferedInputStream and
> InputStream?
>


An InputStream has to make an operating system call every time
you call its read() method. This can be very inefficient in terms
of cpu usage. A BufferedInputStream can call the operating system
just once and collect a whole array of bytes, and then service
many read() calls from its local buffer before going back to the
operating system for more. This can improve performance by a
factor of 10 or more.

Steve
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-06-2005
On Wed, 05 Oct 2005 21:44:38 +0200, Andersen
<(E-Mail Removed)> wrote or quoted :

>What is the fundamental difference between BufferedInputStream and
>InputStream?


another answer is BufferedInputStream adds a readLine method.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Gordon Beaton
Guest
Posts: n/a
 
      10-06-2005
On Thu, 06 Oct 2005 17:51:46 GMT, Roedy Green wrote:
> another answer is BufferedInputStream adds a readLine method.


Since when?

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
 
Reply With Quote
 
Harry Bosch
Guest
Posts: n/a
 
      10-06-2005
>since when<
I think someone is thinking of a BufferedReader

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-06-2005
On 6 Oct 2005 20:12:01 +0200, Gordon Beaton <(E-Mail Removed)> wrote or
quoted :

>> another answer is BufferedInputStream adds a readLine method.

>
>Since when?


oops. I should have said BufferedReader adds readLine to a Reader.

In the days before Readers could you not say

System.in.readLine() ??? If not, how DID you read lines from the
console?
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
confused: Socket InputStream != ServerSocker InputStream R Java 5 03-13-2005 07:26 AM
Why do BufferedInputStream improve performance? Marc Twain Java 5 01-15-2004 07:17 PM
bad I/O performance in BufferedInputStream Jimmy Zhang Java 1 10-31-2003 04:40 AM
reset issue in bufferedInputStream Jimmy Zhang Java 6 10-15-2003 08:00 PM
FileInputStream alone VS BufferedInputStream wrapped FileInputStream Krick Java 2 08-28-2003 01:25 AM



Advertisments