473,382 Members | 1,651 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

DataOutputStream vs BufferedOutputStream

65
generally i see that BufferedOutputStream objects are wrapped with DataOutputStream, what is the reason for this design?
why do coders prefer this style instead of doing operations on
BufferedOutputStream objects.
i am newbie to java, i will appreciate if the explanation is clear enough for a beginner to understand
e.g:

Expand|Select|Wrap|Line Numbers
  1. DataOutputStream out2 = 
  2. new DataOutputStream( 
  3. new BufferedOutputStream(new FileOutputStream("Data.txt"))
  4. );
Jul 27 '07 #1
1 17546
JosAH
11,448 Expert 8TB
generally i see that BufferedOutputStream objects are wrapped with DataOutputStream, what is the reason for this design?
why do coders prefer this style instead of doing operations on
BufferedOutputStream objects.
i am newbie to java, i will appreciate if the explanation is clear enough for a beginner to understand
e.g:

Expand|Select|Wrap|Line Numbers
  1. DataOutputStream out2 = 
  2. new DataOutputStream( 
  3. new BufferedOutputStream(new FileOutputStream("Data.txt"))
  4. );
A DataOutputStream can write ints, longs and other primitive data types.
A BufferedOutputStream can just buffer a bunch of bytes. One stream can do
things the other can't and vice versa. Wrapping them (in the correct order) offers
you all the functionality, i.e. you can write ints, longs and other primitive data
types to a buffered stream.

Also read the article in the Java Articles section about Decorators.

kind regards,

Jos
Jul 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John Thorner | last post by:
Hi, I am working on a small java client and server program pair which at client side packetizes data (such as jpeg image file) and appends some header info for each packetized packet. At the...
0
by: Alexandros Karypidis | last post by:
Hi all, I would like some advice regarding the following design issue: I would like to be able to exchange data in XDR format. I was thinking of writing a pair of I/O streams in the same...
0
by: netgeni59 | last post by:
Hello fellow C# friends, I am trying to write a C# TCP client that was formerly written in Java. The server must still remain in Java. I cannot get text data from the C# client to be received...
3
by: danibangelov | last post by:
Hello, I am writing a proxy.When a proxy works like transparent "clientOut.write(response, 0, responseLength);" clientOut is "BufferedOutputStream clientOut = new...
4
needhelp123
by: needhelp123 | last post by:
what is the difference between following data and when we use each one.. FileInputStream FileOutputStream DataInputStream DataOutputStream BufferedInputStream BufferedoutputStream
3
by: spasavvas | last post by:
Hi I am trying to create a server – client model where client send a file and when server receive the file send back an ack msg. My code is: import java.net.*; import java.io.*; class...
4
by: Asylus | last post by:
Thank you in advance for any help you may be able to provide. I am trying to create a file using DataOutputStream. I'm using the following code to write the file: public static void...
2
by: JohnLorac | last post by:
Hello, I'm trying to load and write file on local disc drive using signed javascript file. But I have experienced problem running this url: ...
5
by: JohnLorac | last post by:
Hello, can somebody help me with saving file into local disk using javascript? I made some sample code which unfortunately won't work :(. Applet sample file: public class IO extends...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.