views:

52

answers:

2

I have been coding Java for a while, but I have to admit that I don't get streams, buffers, etc. 100%

I have tried to find a good tutorial on the subject that explains the reasoning behind them and their patterns of usage, but I couldn't find any. Only short, isolated snippets that don't help.

Is there something out there?

+2  A: 

The Basic I/O tutorial covers this and does go into some detail.

Robert Christie
A: 

When you get data from a stream, it is immediately going and fetching the requested bits and pieces directly from the source, similarly to listening to online an radio broadcast. It's like a strictly live feed.

A buffer gets more than just what was requested of the source and stores it in memory so there are not as many requests to get more smaller pieces (constant IO or network bandwidth). This is similar to downloading a radio broadcast and then listening to it... skipping around/going back will not cause extra fetch calls as all/most of the data is already present.

Kavon Farvardin