Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8008555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:10:24+00:00 2026-06-04T18:10:24+00:00

A DataOutputStream can wrap a FileOutputStream, but I don’t understand why it has been

  • 0

A DataOutputStream can wrap a FileOutputStream, but I don’t understand why it has been used here.

FileOutputStream fos = new FileOutputStream(args[0]);
DataOutputStream dos = new DataOutputStream(fos);
dos.writeByte('j');

The last line does the same as fos.write('j'); What does DataOutputStream add in this situation? i.e. why is there?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:10:26+00:00Added an answer on June 4, 2026 at 6:10 pm

    Streams in Java are defined according to the Decorator design pattern.

    This means that you can compose a specific functionality (implemented inside a specific stream class) with another stream. This allows you to customize what you can do with streams. In your specific example

    • a FileOutputStream is a concrete component which provides the functionality to write to a stream that is mapped to a File
    • a DataOutputStream is a concrete decorator that, attached to another decorator or component, is able to extend the functionality by giving you a way to write primitives onto the stream, without caring about what there is in the underlying chain of decoration
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having quite a problem here, and I think it is because I don't
This should be easy, but I can't get my head around it right now.
i have a simple http client server. here client can download from the server.
i am trying to implement DataOutputStream in php (DataOutputStream from java language) in java
When i have a file transfer and the device loses internet connection the DataOutputStream.write
Java Code need to write an equivalent in objectiveC. CAn you please help me
I need to download a file using Java. I can use this code to
How can I, within my application, edit a file in the /system/ directory? Do
Do you know how can I keep alive a socket connection if I do
I have to write 7 byte Integer value to DataOutputStream, this Integer contains 15

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.