Splitting a large object into multiple smaller byte arrays
<p>I have a huge POJO (1G - 6G) that I want to split into multiple byte arrays of 100Kb each. My algo currently is as follows:</p>

<ol>
<li>serialize the large object to a large byte[] I.e. 1G object to 1G byte[]</li>
<li>Split the large byte[] into smaller 100k byte[]</li>
</ol>

<p>However this creates a lot of memory pressure as I now have 1 object + 1 byte[] + some 100k byte[]</p>

<p>Splitting a large file into multiple smaller byte arrays is relatively easy to do with the FileInputStream as follows</p>

<pre><code>File file = new File("asd");
FileInputStream fis = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(fis);
byte[] buffer = new byte[1024*1024*10];
int n = -1;
while((n = bis.read(buffer))!=-1) {
  bos.write(buffer,0,n):
}
</code></pre>

<p>How can I achieve the same for regular POJO's? Is there a way I can read the object into 100K byte arrays iteratively rather than creating the large byte array and splitting it?</p>
