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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:25:23+00:00 2026-05-27T03:25:23+00:00

I want to write a byte[] data to a file and I found this

  • 0

I want to write a byte[] data to a file and I found this code:

public static void writeByte(String filename, byte[] data){

    BufferedOutputStream bos = null;

    try
    {
    //create an object of FileOutputStream
    FileOutputStream fos = new FileOutputStream(new File(filename));

    //create an object of BufferedOutputStream
    bos = new BufferedOutputStream(fos);


    /*
    * To write byte array to file use,
    * public void write(byte[] b) method of BufferedOutputStream
    * class.
    */
    System.out.println("Writing byte array to file");

    bos.write(data);

    System.out.println("File written");
    }
    catch(Exception fnfe)
    {
    System.out.println("exception");
    }
 }

This seems to work but I can’t open the file to see the data…it says the “file is of an unknown type”. Data was written because the file size is 25.5KB. My question is, how can I view the contents? Is there an extension that I have to use? Or do I need a special editor to open it? (Tried geany and gedit…)

  • 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-27T03:25:24+00:00Added an answer on May 27, 2026 at 3:25 am

    Use a hex file editor to view the contents. Such as:

    • GNOME: ghex
    • Windows: HxD
    • OS X: Hex Fiend

    These are just the ones I use. They are not necessarily the best hex editors.

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

Sidebar

Related Questions

String data=this we want append in that file; byte[] getbyte = data.getBytes(); outputstream.write(getbyte); outputstream.flush();
I want to write a raw byte/byte stream to a position in a file.
I want to use ADO.net to extract some data from an Excel file. This
I want to save space when writing my data to file. That is I
I have a BitSet and want to write it to a file- I came
I've just started using SQLite and I want to write all my application data
i want to read\write a binary file which has the following structure: The file
I'm Trying to Write Logs to Custom Log.txt File on Android File using this
I want my web application users to download some data as an Excel file.
To read/write binary files, I am using DataInputStream/DataOutputStream, they have this method writeByte()/readByte(), but

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.