Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Java Input/OutputStreams vs. Input/OutputReaders

Java Input/OutputStreams vs. Input/OutputReaders
Thread Tools
Professional Poster
Join Date: Oct 2001
Status: Offline
Reply With Quote
Jul 18, 2004, 07:08 PM
 
Still going through the tutorial, I encounter yet another thing that's kinda bugging me. Java streams are seperated into those that read/write bytes, and those that read/write characters (I think).

Why would one want to use say a DataOutputStream instead of a FileWriter? Can someone help me understand when I would want to use which in what situations (and could you include an example that has to do with sockets?).
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Jul 18, 2004, 08:10 PM
 
Originally posted by itistoday:
Still going through the tutorial, I encounter yet another thing that's kinda bugging me. Java streams are seperated into those that read/write bytes, and those that read/write characters (I think).

Why would one want to use say a DataOutputStream instead of a FileWriter? Can someone help me understand when I would want to use which in what situations (and could you include an example that has to do with sockets?).
Classes that write bytes are faster. There is less overhead. When I had to write a program to parse fixed-length call data records (typically 8-15GB per file), I wrote it originally as BufferedReader and BufferedWriter. When I rewrote it to use FileInputStream the performance tripled.

It just depends on the purpose of the reader as to which you use. The character readers are easier to work with if they meet your needs.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
   
Thread Tools
Forum Links
Forum 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 On
Top
Privacy Policy
All times are GMT -5. The time now is 01:03 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2