Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2007

Tip: Looking for answers? Try searching our database.

java api design q: Reader/Writer vs InputStream/OutputStream

Thread view: 
emrefan - 07 Dec 2007 05:08 GMT
I am curious as to whether my understanding of the design philosophy
behind the design of this part of the java API is correct. I think the
Reader/Writer clan is for handling Characters (or just chars?) and the
Input/OutputStream clan is for  handling bytes or bytes that make up
Objects. Is this right? Once I thought I always needed a Reader/Writer
to read/write things from/to streams, but obvious enough now that's
just not true.
Lew - 07 Dec 2007 05:44 GMT
> I am curious as to whether my understanding of the design philosophy
> behind the design of this part of the java API is correct. I think the
[quoted text clipped - 3 lines]
> to read/write things from/to streams, but obvious enough now that's
> just not true.

You're nearly correct.

Readers and Writers manipulate chars under an encoding (UTF-8, ISO8859-2,
etc.), also called "text".  Streams manipulate bytes, not necessarily bytes
that make up an arbitrary object.  (Most just manipulate byte arrays.)  These
data are also called "binary data".

Readers and Writers are wrappers for streams.  They apply an encoding to the
data to turn them from text into binary data (in the case of Writers) and from
binary back to text (in the case of Readers).  The binary data in turn are run
through the underlying streams.

Character is a Java class.  The concept of a class no longer has any meaning
once data are on the stream.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.