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

  • Home
  • SEARCH
  • 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 8474847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:44:04+00:00 2026-06-10T17:44:04+00:00

All I want to do is read characters from a notepad and convert it

  • 0

All I want to do is read characters from a notepad and convert it to bytes and save it another file.

“a.txt” has the simple text in notepad “Hello World!”

However, in “b.txt”, I still see the human readable characters instead of the byte values. I also noticed that when I do a System.out.print(ba), it prints the bytes.

Can anyone tell me why Java does not write the byte values to “b.txt”?

import java.io.*;

class a {
    static int f;
    static String s;

    public static void main(String args[]) 
    throws IOException {
        BufferedReader  br = new BufferedReader(new FileReader ("a.txt"));
        BufferedOutputStream w = new BufferedOutputStream(new FileOutputStream("b.txt"));

        byte ba[] = new byte[1024];

        while((s=br.readLine())!=null) {
            ba = s.getBytes();
            System.out.print(ba);
            w.write(ba);
        }
    w.flush();
    w.close();
    br.close();
    }
}
  • 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-10T17:44:05+00:00Added an answer on June 10, 2026 at 5:44 pm

    You’re writing raw byte values to the file.
    Notepad reads them as ASCII text.

    If you open either file in a hex editor, you will see the actual byte values.

    If you want to see byte values in Notepad, you’ll need to print each byte to the file as a string, typically separated by spaces so that you can see each one.

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

Sidebar

Related Questions

i want to read from a text file in C#. But I want all
Basically I want to read and write to a file then save all the
What I want to do is read a line from text file which contains
I want to read all the contacts from the phone but i am unable
I want to read the company table and take out all possible suffixes from
I want to read a String and toUpper all the characters. import Data.Char main
I want to read a text file and store its contents in an array
I am trying to read in data from a text file and do a
I have a text file that contains two lines of numbers, all I want
I have a text file I want to read, but exclude lines that contain

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.