473,473 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Streams

I'm reading up on streams and I have two articles that
seem to conflict with each other. One article describes
streams and lists a few of the major ones (FileStream,
Memory Stream, Network Stream, etc.). It then goes on to
discuss the restriction that streams only read bytes or
byte arrays that the .net framework provides a
StreamReader and StreamWriter class to do type conversions
to and from bytes when using streams.
The second article describes the StreamReader and
StreamWriter class as streams themselves and demonstrates
them using the File class object to open a file and
read/write to it using the returned StreamReader and
StreamWriter objects of the static file methods.

So what is technically correct? Are the StreamReader and
StreamWriter classes actually streams or just wrapper
classes for converting data to and from bytes? Do we
actaully ever deal with streams directly or is it our use
of the StreamReader and StreamWriter that gives us access
to the "actual" stream objects?

I hope this is an interesting thought for someone to
ponder.
Thanks, Chris
Nov 20 '05 #1
1 2394
Chris,
The way I view it is to be considered a "Stream" you need to inherit from
System.IO.Stream. As this allows you to use one of these objects where ever
you can use a Stream object.

FileStream, MemoryStream, NetworkStream all inherit from System.IO.Stream so
they are streams.
So what is technically correct? Are the StreamReader and
StreamWriter classes actually streams or just wrapper
classes for converting data to and from bytes? StreamReader & StreamWriter are wrapper classes for converting streams to &
from 'text'.

BinaryReader & BinaryWriter are wrapper classes for converting streams to &
from 'binary'. These are useful when you want to read & write the actual
bits not a Text file.
Do we
actaully ever deal with streams directly or is it our use
of the StreamReader and StreamWriter that gives us access
to the "actual" stream objects? Yes I deal with streams directly. And yes I user StreamReader & StreamWriter
to give me access to actual stream objects. I also use BinaryReader &
BinaryWriter to give me access to actual stream objects.

It really depends on what I am doing & trying to accomplish. Most of the
time I use either pair of Reader/Writer classes (stream & binary). If I am
doing serialization or some very specific stream stuff I use the stream
class itself.

Hope this helps
Jay
"Chris" <ch****@unr.edu> wrote in message
news:10****************************@phx.gbl... I'm reading up on streams and I have two articles that
seem to conflict with each other. One article describes
streams and lists a few of the major ones (FileStream,
Memory Stream, Network Stream, etc.). It then goes on to
discuss the restriction that streams only read bytes or
byte arrays that the .net framework provides a
StreamReader and StreamWriter class to do type conversions
to and from bytes when using streams.
The second article describes the StreamReader and
StreamWriter class as streams themselves and demonstrates
them using the File class object to open a file and
read/write to it using the returned StreamReader and
StreamWriter objects of the static file methods.

So what is technically correct? Are the StreamReader and
StreamWriter classes actually streams or just wrapper
classes for converting data to and from bytes? Do we
actaully ever deal with streams directly or is it our use
of the StreamReader and StreamWriter that gives us access
to the "actual" stream objects?

I hope this is an interesting thought for someone to
ponder.
Thanks, Chris

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ronald Legere | last post by:
The new itertools stuff is pretty cool. One thing that bothers me though is that there seems to be no way to copy an iterator. How does one work around this? Is there a trick that I am missing? ...
10
by: Roy Smith | last post by:
I've been running some benchmarks to compare streams and stdio performance. I've always suspected stdio was faster, but was astonished to discover how much faster. I timed the following running...
3
by: Tron Thomas | last post by:
What does binary mode for an ofstream object do anyway? Despite which mode the stream uses, operator << writes numeric value as their ASCII representation. I read on the Internet that it is...
8
by: bonj | last post by:
hello I hope somebody can help me get my head around this area of 'stream' programming... I know that streams are very fashionable nowadays so hopefully there'll be lots of replies. ;-) ...
11
by: Kobu | last post by:
I have a question about C's abstract "streams" (that I can't seem to FULLY understand from reading several tutorials). Streams seems to suggest that input can be treated continously if needed....
2
by: Peter Rilling | last post by:
One nice thing about collections and arrays is that they implement the IEnumerator and IEnumerable interfaces which allow for more then one iterator to walk the list of items without affecting the...
2
by: bonk | last post by:
Hello how do I connect streams in c# ? Imagine the followung scenario: I have a StreamWriter that writes Text to a Stream. How can I tell that Stream to pass that Data to another Stream...
2
by: Abhishek | last post by:
what are the STDUPDATE, STDERR, STDOUT and STDIN streams and how does one access these streams in C language. I am aware of the function fprintf(FILE *fp, char * format, char *s) which puts the...
4
by: floppyzedolfin | last post by:
Hello! I'm actually encoding an encryption / decryption program. The encryption programes takes a file path in parameter, and encrypts the contents of the file and stores that into another file. ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.