Results 1 to 3 of 3

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

  1. #1

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

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

  3. #3
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    335

    Default

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

Similar Threads

  1. ERROR: Context initialization failed
    By makhlo in forum Architecture
    Replies: 8
    Last Post: Jul 11th, 2008, 01:41 AM
  2. Context initialization failed
    By kanonmicke in forum Container
    Replies: 7
    Last Post: Sep 29th, 2005, 12:35 AM
  3. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  4. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM
  5. Replies: 4
    Last Post: Nov 5th, 2004, 03:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •