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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:56:40+00:00 2026-05-22T17:56:40+00:00

In C++, I’ve created a class called Serializer. And I want to duplicate the

  • 0

In C++, I’ve created a class called Serializer. And I want to duplicate the functionality in Java. Here’s how Serializer works.

Serializer s;
s.writeString(myString); // automatically converted to Big-Endian unicode string with length prepended.
s.writeInt(myInt); // automatically converted to Big-Endian integer (swizzled if necessary)
s.writeObject(myObject); // which implements the Serializable interface
    {
        s.writeInt(myObjectId); // internally, it writes the data that I want to serialize.
        ...
    }

ZlibCompressor.compress(s); // 's' is compressed
    {
        bytes = s.getBytes(); // internally, it gets bytes, ...
        compressFunc(bytes); // compress them
        s.overwrite(bytes); // and overwrites
    }

AESCipher.encrypt(s); // similarly, 's' is encrypted

// and the reverse in the same file, using the same all-in-one class to manipulate byte data.

AESCipher.decrypt(s);
ZlibCompressor.decompress(s);

s.readString(myString);
s.readInt(myInt);
s.readObject(myObject);

And of course, these are the other few functions you can do (copied and pasted from C++):

ByteArray Split(const Uint32& start, const Uint32& size);

inline Uint32 GetSize() const                                       { return mBytes.size(); }
inline const Uint32& GetPos() const                                 { return mPos; }
inline Bool IsEmpty() const                                         { return mBytes.empty(); }
inline const Bool& IsError() const                                  { return mError; }

inline void Resize(const Uint32& size, const Byte& val = 0)         { mBytes.resize(size, val); }
inline void SetPos(const Uint32& pos) const                         { mPos = pos; }
inline void Reset() const                                           { mPos = 0; mError = false; }
inline void Clear()                                                 { mBytes.clear(); Reset(); }
inline void Push(const Byte& x)                                     { mBytes.push_back(x); }
inline void Pop()                                                   { mBytes.pop_back(); }
  • Is there any in-built class that does that, freely able to manipulate byte data?
  • If there isn’t, can you use the Input and Output stream together?
  • If you can’t, how do you convert between InputStream and OutputStream?
  • Is there any other approach to solving this problem?

Side Note: All the byte data can be in memory. Memory is not an issue.

Thank you.

  • 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-22T17:56:40+00:00Added an answer on May 22, 2026 at 5:56 pm

    Java has an object serialisation system, which sounds like a good fit for what you want to do. Quick summary:

    • Have your class implement java.io.Serializable, and add a private static final long serialVersionUID field (use any value you like—usually I just start with 1).
    • Mark all fields you don’t want to serialise as transient; all non-transient fields will be serialised.
    • Ensure that all fields you want to serialise are either primitive or are also serialisable types—all non-serialisable types must be transient.
    • Change the serialVersionUID whenever you make changes to the fields that get serialised. Usually I just bump the value by 1.
    • For custom serialisation, you can implement the readObject and writeObject methods.
    • For seriously custom serialisation, there’s also java.io.Externalizable.

    To actually serialise or deserialise your objects, use the DataOutputStream and DataInputStream classes. And yes, you can wrap the streams with compression and/or encryption. 🙂

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I

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.