×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    9

    java.io.IOException: Too many file handles open while reading images from gallery

    I have problem while i'm reading images from gallery. If the count of images is less then 6 it works fine, but otherwise it thows exception. My code:

    Code:
          for (int i = 0; i < paths.size(); i++) { //path is Vector of strings
                try {
                    FileConnection fc = (FileConnection) Connector.open((String) paths.elementAt(i));
                    Image img = Image.createImage(fc.openInputStream());
                    fc.close();
                    //fc = null; //i have tried also this solution
                    Image pi = createThumbnail(img);
                    g.drawImage(pi, posX, posY, 0);
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
                posX += 80;
                if (posX == 240) {
                    posX = 0;
                    posY += 130;
                }
            }
    I'm doing something wrong?

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: java.io.IOException: Too many file handles open while reading images from gallery

    Quote Originally Posted by saquas View Post
    I have problem while i'm reading images from gallery. If the count of images is less then 6 it works fine, but otherwise it thows exception. My code:

    Code:
          for (int i = 0; i < paths.size(); i++) { //path is Vector of strings
                try {
                    FileConnection fc = (FileConnection) Connector.open((String) paths.elementAt(i));
                    Image img = Image.createImage(fc.openInputStream());
                    fc.close();
                    //fc = null; //i have tried also this solution
                    Image pi = createThumbnail(img);
                    g.drawImage(pi, posX, posY, 0);
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
                posX += 80;
                if (posX == 240) {
                    posX = 0;
                    posY += 130;
                }
            }
    I'm doing something wrong?
    This may be due to the memory issue, use a memory monitor any see if the peek hit. After reading a image - try to null all variables and then only re-create - if needed even GC can be called.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  3. #3
    Registered User
    Join Date
    Jun 2012
    Posts
    9

    Re: java.io.IOException: Too many file handles open while reading images from gallery

    Ok, thank you very much for your advice. It helped. As you said it was enough to set fileconnection to null and call gc.

Similar Threads

  1. JSR-72: IOException: Too many file handles opened
    By bharatpatel85 in forum Mobile Java General
    Replies: 3
    Last Post: 2012-07-21, 09:57
  2. IOException java.io.IOException: 40-Error in HTTP operation
    By @RainierLabs in forum Mobile Java General
    Replies: 2
    Last Post: 2011-05-06, 14:23
  3. java.io.IOException: connection already open
    By ayyanar7 in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2010-03-26, 10:22
  4. Getting java.io.IOException: TCP open
    By ajit.ps1 in forum Mobile Java General
    Replies: 1
    Last Post: 2008-03-25, 12:34
  5. Error Loading Images java.io.IOException
    By sushant_125 in forum Mobile Java General
    Replies: 1
    Last Post: 2005-01-05, 09:53

Posting Permissions

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