title: Write and read multiple byte[] in file with Java
body: <p>I have to write byte arrays in a file. I can't do it in one time so I can't put my arrays in a container. Also the size of my arrays is variable.
  Secondly, the file is very huge, so I have to split it, in order to read it array by array.</p>
  
  <p>How can I do that ? I tried to write line by line my byte arrays  but I haven't been able. How can I put a separator between my arrays and after split it over this separator ?</p>
  
  <p>EDIT : </p>
  
  <p>I tried this :</p>
  
  <pre><code>ByteArrayOutputStream bos = new ByteArrayOutputStream();
  ObjectOutput out = new ObjectOutputStream(bos);
  out.writeObject(byteArray);
  </code></pre>
  
  <p>But, I execute this code several times, so the ObjectOutputStream adds each time a new header which corrupt the file.</p>
  
  <p>I also try : </p>
  
  <pre><code>out.write(byteArray);
  </code></pre>
  
  <p>but I couldn't separate my arrays. So I tried to append a '\n', which didn't work. After I was looking for library like FileUtils in order to write byte[] line by line but I didn't find.</p>