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 8730875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:06:41+00:00 2026-06-13T09:06:41+00:00

I wrote the code below to familiarise myself with DataOutputStream. I suppose there would

  • 0

I wrote the code below to familiarise myself with DataOutputStream. I suppose there would be some kind of 11010111 binary in the file where I output the data, instead, there are just some readable strings. My question is: shouldn’t there be binary data in the file while DataOutputStream is used to output data?

Code:

FileOutputStream fos = null;
try {
    fos = new FileOutputStream("myData.dat");
} catch (FileNotFoundException e) {
    System.out.println("File Not Found!!");
    System.exit(-1);
}
DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(fos));
try {
    dos.writeChars("HELLO WORLD!!!\n");
    dos.writeChars("HELLO PRETTIES!!!\n");
    dos.writeChars("HELLO KITTY!!!");
    dos.flush();
    dos.close();
    fos.close();
} catch (IOException e1) {
    e1.printStackTrace();
}
FileInputStream fis = null;
try {
    fis = new FileInputStream("myData.dat");
} catch (FileNotFoundException e) {
    System.out.println("File Not Found!!");
    System.exit(-1);
}
BufferedReader br = new BufferedReader(new InputStreamReader(
        new DataInputStream(fis)));
String s;
try {
    while ((s = br.readLine()) != null) {
        System.out.println(s);
    }
    br.close();
    fis.close();
} catch (IOException e) {
    e.printStackTrace();
}
  • 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-13T09:06:42+00:00Added an answer on June 13, 2026 at 9:06 am

    All data in a computer is binary. Some binary data may be readable text, and this is what happens in your case.

    The writeChars method writes each char of the String as two bytes. If you opened the file in a hex viewer you’d see that there’s a NUL (00) byte before the ASCII code of each letter. When you open the file in a text editor, it interpretes the bytes in the file as text, because that’s what text editors do: read a bunch of (binary) data and show it to you as text.

    How the editor does this depends on the editor. Either it skips the NUL bytes and shows only the readable bytes, or interpretes the bytes as text encoded in UTF-16LE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is some jQuery code the i wrote to make a simple animation. However
I wrote the code below to split up a fullname from a .csv file
I wrote the code below to output the figure but still need to figure
I want to include jquery.js in myjs.js file. I wrote the code below for
I wrote the code below that successfully gets a random line from a file;
I wrote the code below : 1. MyClass[] origArr=new MyClass[3]; 2. MyClass[] arr1; 3.
So I wrote the code below: jQuery('#contentWrapper').delegate(.addButton, click, function(){ addRow(jQuery(this)); }); function addRow(thisButton){ var
I have wrote the code below which was taken from Java How to program
I have to perform async execution, and i have wrote the below code var
Below is the code which I wrote to display a tooltip content. As the

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.