title: Base64 partial encoding
body: <p>I have to encode in base64 an array of bytes (that is a byte stream of a Zipfile) but the array is too big. So I split the array in two parts, encode the first half, then the second one, and in the end I append the second part to the first part. The thing is that sometimes when i decode the result the zipfile seems to be corrupted.</p>
  
  <pre><code>    FileInputStream fis = new FileInputStream(new File(filePath));
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
  
      while((len = fis.read(buffer)) &gt;= 0) {
          baos.write(buffer);
      }
  
      byte[] bArray = baos.toByteArray();
  
      int bArrayLength = bArray.length;
  
      byte[] part1 = new byte[bArray.length / 2];
      byte[] part2 = new byte[ (bArrayLength%2 == 0) ? (bArray.length / 2) : (bArray.length / 2 + 1)];
  
      System.arraycopy(bArray, 0, part1, 0, part1.length);
      System.arraycopy(bArray, part1.length, part2, 0, part2.length);
  
      resultArray[0] = Base64.encodeBytes(part1);
      resultArray[1] = Base64.encodeBytes(part2);
  </code></pre>
  
  <p>What is the problem? Is that split that causes the issue?</p>