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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:29:07+00:00 2026-05-21T17:29:07+00:00

I have a file that contains bytes, chars, and an object, all of which

  • 0

I have a file that contains bytes, chars, and an object, all of which need to be written then read. What would be the best way to utilize Java’s different IO streams for writing and reading these data types?

More specifically, is there a proper way to add delimiters and recognize those delimiters, then triggering what stream should be used? I believe I need some clarification on using multiple streams in the same file, something I have never studied before. A thorough explanation would be a sufficient answer.

  • 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-21T17:29:08+00:00Added an answer on May 21, 2026 at 5:29 pm

    As EJP already suggested, use ObjectOutputStream and ObjectInputStream an0d wrap your other elements as an object(s). I’m giving as an answer so I could show an example (it’s hard to do it in comment) EJP – if you want to embed it in your question, please do and I’ll delete the answer.

    class MyWrapedData implements serializeable{
        private String string1;
        private String string2;
        private char   char1;
        // constructors
        // getters setters
    }
    

    Write to file:

    ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(fileName));
    out.writeObject(myWrappedDataInstance);
    out.flush();
    

    Read from file

    ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileName));
    Object obj = in.readObject();
    MyWrapedData wraped = null;
    if ((obj != null) && (obj instanceof MyWrappedData))
        wraped = (MyWrapedData)obj;
    // get the specific elements from the wraped object
    

    see very clear example here: Read and Write

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

Sidebar

Related Questions

I have WCF service that returns an object that contains an array of bytes
Currently I have a byte[] that contains all the data of an image file,
Let's say we have a binary file that contains 2 bytes that form an
I have a File that COntains Strings in This Format: ACHMU)][2:s,161,(ACH Payment Sys Menus
I have a file that contains this <!-- CordovaVersion --> I want to replace
I have a file that contains: foo1 = 1 foo2 = 2 foo3 =
I have a file that contains the following in a csv file; country,region,city,postalCode,metroCode,areaCode I
I have Text file that contains data separated with a comma , . How
I have a file that contains around thousands of lines. Format of every line
I have a file that I set using PowerShell that contains the version number

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.