Guest User

Untitled

a guest
Apr 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. private void processFile(Cipher cipher,InputStream inputStream, OutputStream outputStream) throws EmprisException{
  2. byte[] tempInputBuffer = new byte[1024];
  3. int len;
  4. try {
  5. while ((len = inputStream.read(tempInputBuffer)) != -1) {
  6. byte[] tempOutputBuffer = cipher.update(tempInputBuffer, 0, len);
  7. if ( tempOutputBuffer != null ) outputStream.write(tempOutputBuffer);
  8. }
  9.  
  10. byte[] obuf = cipher.doFinal();
  11. if ( obuf != null ) outputStream.write(obuf);
  12. }catch (IOException | IllegalBlockSizeException | BadPaddingException e) {
  13. e.printStackTrace();
  14. }catch (Exception e) {
  15. e.printStackTrace();
  16. }
  17. }
  18.  
  19. java.lang.OutOfMemoryError: Java heap space
  20. at java.util.Arrays.copyOf(Arrays.java:3236)
  21. at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
  22. at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
  23. at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
  24. at java.io.OutputStream.write(OutputStream.java:75)
  25. at com.global.empris.common.CryptographyHelper.processFile(CryptographyHelper.java:49)
  26. at com.global.empris.common.CryptographyHelper.encryptFile(CryptographyHelper.java:105)
Add Comment
Please, Sign In to add comment