How do you get just the image icon name of a jlabel rather than the path
<p>I was wondering how do I get just the JLabel image name rather than the whole path, I try to use </p>

<pre><code>jLabel.getIcon();
</code></pre>

<p>but it uses the whole path rather than just the name (ie of name, berries.png). When I use getIcon(), the resuult is:</p>

<blockquote>
  <p>file:/C:/Users/lolne/Desktop/FCaWfD%20-%20Desktop%20Updated%20Version/build/classes/resources/quiz/berries.png</p>
</blockquote>

<p>and I only wish for the ending part of berries.png to found. I am using this code for a food web game for a school assignment and this is the code where it is used: </p>

<pre><code>public void checkResults(){

    JLabel[] consumers = {
        consumer1,
        consumer2,
        consumer3,
        consumer4,
        consumer5,
    };

    switch(RandomNumber.randomNumber){
        case 1:
            if(producer.getIcon().equals(producers[0])){
                correct++;
            }else{
                producer.setBorder(BorderFactory.createLineBorder(Color.RED));
            }

            for(int i = 0; i &lt; 5; i++){
                if(consumers[i].getIcon().equals(consumers1.get(i))){
                    correct++;
                }else{
                    consumers[i].setBorder(BorderFactory.createLineBorder(Color.RED));
                }
            }
        break;

        case 2:
            if(producer.getIcon().equals(producers[1])){
                correct++;
            }else{
                producer.setBorder(BorderFactory.createLineBorder(Color.RED));
            }

            for(int i = 0; i &lt; 5; i++){
                if(consumers[i].getIcon().equals(consumers2.get(i))){
                    correct++;
                }else{
                    consumers[i].setBorder(BorderFactory.createLineBorder(Color.RED));
                }
            }
        break;

        case 3:
            if(producer.getIcon().equals(producers[2])){
                correct++;
            }else{
                producer.setBorder(BorderFactory.createLineBorder(Color.RED));
            }

            for(int i = 0; i &lt; 5; i++){
                if(consumers[i].getIcon().equals(consumers3.get(i))){
                    correct++;
                }else{
                    consumers[i].setBorder(BorderFactory.createLineBorder(Color.RED));
                }
            }
        break;
    }
}
</code></pre>

<p>All in all my question is, "How do I get the name of the image itself rather than the whole path of the image"</p>