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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:30:40+00:00 2026-05-26T07:30:40+00:00

In Java… I have data stored in a BufferedReader. (I got it as a

  • 0

In Java…

I have data stored in a BufferedReader. (I got it as a response to an HTTP post request.)

How do I write this (binary) data to a file?

I know how to write Strings to files, but how do I take the data in the BufferedReader and put it into a file.

Thanks in advance!

  • 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-05-26T07:30:41+00:00Added an answer on May 26, 2026 at 7:30 am

    Do not use a Reader to get bytes. Reader is used for reading character data, not binary data. Use the InputStream directly.

    void write(InputStream is, OutputStream os) throws IOException {
        byte[] buf = new byte[512]; // optimize the size of buffer to your need
        int num;
        while ((num = is.read(buf)) != -1) {
          os.write(buf, 0, num);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

java.util.logging.Logger override (overwrites) the file data instead of add to end of file. Is
java.util.Date gets stored as 2010-09-03 15:33:22.246 when the SQL data type is timestamp, how
(Java question) If I reference a field in an inner class, does this cause
Java Newbie here. I have a JFrame that I added to my netbeans project,
Java's unary plus operator appears to have come over from C, via C++. int
java.lang.UnsupportedOperationException: This operation is not supported on Query Results at org.datanucleus.store.query.AbstractQueryResult.contains(AbstractQueryResult.java:250) at java.util.AbstractCollection.retainAll(AbstractCollection.java:369) at
java.lang.IOException, path to file cannot be created. my catch is working by dont know
java.lang.annotation.ElementType : A program element type. The constants of this enumerated type provide a
Java programmers and API seems to favor explicit set/get methods. however I got the
Java Swing applications by default have the Java coffee cup icon appear in 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.