Announcement Announcement Module
Collapse
No announcement yet.
Reading huge files(>50 k) causes out of memory error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reading huge files(>50 k) causes out of memory error

    I have mapped a Blob to a byte[] array and trying to save into Oracle database.
    My code:
    Email email = new Email();
    File attachment = new File("C:/temp/full_cream.gif");
    if (!attachment.exists()) {
    assertTrue(true);
    return;
    }

    email.setEmailattachmentfilename(attachment.getNam e());

    InputStream is = new FileInputStream(attachment);
    byte[] data = new byte[is.available()];
    is.read(data);
    is.close();

    email.setEmailattachment(data);

    Error:
    As the file is very huge and trying to read all at one time into the byte[] array am getting an out of memory exception.
    Any help on this is highly appreciated.

    Thanks.

  • #2
    Tried adjusting the JVM memory size of the web container? http://java.sun.com/docs/hotspot/VMOptions.html

    Comment


    • #3
      Modify the Email class so that it will accept an InputStream rather than a byte[] for the emailattachment property?

      Comment

      Working...
      X