473,756 Members | 3,499 Online
Bytes | Software Development & Data Engineering Community
+ 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 2426
Chris,
The way I view it is to be considered a "Stream" you need to inherit from
System.IO.Strea m. 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.Strea m 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
2963
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? Without being able to 'split' an iterator, I can't think of how to do some of the cool things you can do with lazy lists in Haskell. It seems quite often you want to be able to do this 'splitting', and if I
10
13835
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 into /dev/null, as well as the same loop using printf(). int main () { for (int i = 0; i < 1000 * 1000; ++i) { cout << "i = " << i << '\n'; }
3
3496
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 possible to change the behavior of operator << so it will stream numeric values as their actual values when an ofstream is in binary mode. I did not, however, find any information on how this can be accomplished. What is involved in getting this...
8
2746
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. ;-) Basically I have an operation which the input and output for are streams - a function which receives a certain 'chunk' of data each time it runs, and it runs many times until it has received all the data, in a similar way to a socket. What the...
11
1802
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. Is this true? So far as I know, I can only get a stream to "flow" when there is a '\r'. At that point the '\r' is turned into a '\n' and the whole stream is sent to some abstract area that is now only accessible to my programs (meanwhile, other...
2
1786
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 position of the other iterators. Is there a similar thing with streams? Is there anything in the framework that wraps a stream in such a way that the stream position is decoupled from the stream itself?
2
4033
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 (connect it to another output Stream) ? In java I am used to connect streams to each other via thier Constructors. For example: new BufferedWriter(new OutputStreamWriter(new FileOutputStream("soc.txt"),
2
2860
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 string into the corresponding streams. But can you please tellme where does the content go exactly when we put it into the above streams. In which cases can we see the outpt and in which cases cant we see and why so? It would be great if you can...
4
6229
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. I'm using AES for it is quick, and RSA to encrypt AES, to transmit AES keys (it'll run on two separate computers). Please notice that - this is my first C# code :)
0
9273
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8712
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7244
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5141
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5303
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
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 we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.