title: How to serialize objects together with byte array into a file?
body: <p>I have a java class that contains an inner class and a byte array member, for example <code>KeyValPair hdr</code> and <code>byte[] content</code>, and I'd like to serialize only the inner class <code>hdr</code> and the byte array <code>content</code>, rather than the whole class instance as there are some other unneccesary fields in the class.</p>
  
  <p>I know how to serialize objects using <code>ObjectOutputStream</code>, and I know how to convert an object into a byte array, but I'm not sure whether I can store them at the same time without converting the inner class instance<code>KeyValPair hdr</code> into byte array. If I convert it into byte array and store it together with <code>content</code>, how do I know the length of <code>hdr</code> when deserializing it from file? </p>
  
  <p>Another question is that is it possible to use <code>MappedBytesBuffer</code> together with <code>ObjectOutputStream</code> or something like <code>ByteArrayOutputStream</code>? Because I'm in a scene that requires certain level of performance for I/O and the process might be killed... so is it a good idea to use <code>MappedBytesBuffer</code>?</p>
  
  <p>I'm a newbie to java, so any help is appreciated.</p>