clear the java buffer

Discussion in 'Java' started by Emmanuel Freund, Nov 24, 2004.

  1. I have a strange error:

    With this function:

    public static ImageIcon loadImageIcon(String file, String iconName) {
    return new ImageIcon(file+ '/' + iconName);
    I first rename Image1.jpg to someImage.jpg and call this function with
    So Image1.jpg is loaded and paint (with some other functions of course).
    Then during my execution, I rename Image2.jpg to someImage.jpg and call
    Then the Image loaded is still Image1.jpg.

    Is that possible that Java remember that's the same function called with the
    same variables, and so don't reload the Image and instead take the Image
    from a buffer somewhere?
    And if it's the case, how can we clear the buffer so the Image2.jpg is
    Emmanuel Freund, Nov 24, 2004
    1. Advertisements

  2. Emmanuel Freund

    Ann Guest

    Try closing the file.
    Ann, Nov 24, 2004
    1. Advertisements

  3. I may have missed something, but I used an ImageIcon which takes one string
    and no file in its constructor... So I think all the openning-closing
    operations are done in this constructor to which I don't have access.
    So, how I close a file I haven't open ?
    Emmanuel Freund, Nov 24, 2004
  4. Andrew Thompson, Nov 24, 2004
  5. So?

    Which, if you look at the source of ..
    You'll notice it calls..


    Don't use ImageIcons if you don't want the image cached,
    load the bytes yourself and use ..

    Andrew Thompson, Nov 24, 2004
  6. Thank you very much Andrew, that was the problem.
    Emmanuel Freund, Nov 24, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.