Forum Stats

  • 3,875,419 Users
  • 2,266,914 Discussions
  • 7,912,203 Comments

Discussions

I am getting OutOfMemorryError at (md.update(fileContent.getBytes());) point in below code

User_PSODG
User_PSODG Member Posts: 4 Green Ribbon
edited Oct 6, 2022 8:45AM in Java Programming

 MessageDigest md;

     md = MessageDigest.getInstance("MD5");

     md.update(fileContent.getBytes());

     final Integer integerConst = 16;

     final byte[] byteData = md.digest();

     final StringBuilder sb = new StringBuilder();

     for (final byte element : byteData) {

       sb.append(Integer.toString((element & 0xff) + 0x100, integerConst).substring(1));

     }

     generatedMd5Sum = sb.toString();

Answers