Here you can find the source of loadImage(final String src)
public static BufferedImage loadImage(final String src)
//package com.java2s; /*//w w w . ja v a2 s . c o m * This file is part of WebLookAndFeel library. * * WebLookAndFeel library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WebLookAndFeel library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WebLookAndFeel library. If not, see <http://www.gnu.org/licenses/>. */ import javax.imageio.ImageIO; import javax.swing.*; import java.awt.image.BufferedImage; import java.io.*; import java.net.URL; public class Main { /** * Loads image from specified source file */ public static BufferedImage loadImage(final String src) { return loadImage(new File(src)); } public static BufferedImage loadImage(final File file) { try { return ImageIO.read(file); } catch (final Throwable e) { return null; } } /** * Loads image from URL */ public static ImageIcon loadImage(final URL url) { try { // URLConnection uc = url.openConnection (); // ProxyManager.setProxySettings ( uc ); // InputStream inputStream = uc.getInputStream (); // ImageIcon imageIcon = loadImage ( inputStream ); // inputStream.close (); // return imageIcon; return new ImageIcon(url); } catch (final Throwable e) { return null; } } /** * Loads image from specified resource near class */ public static ImageIcon loadImage(final Class nearClass, final String src) { try { return new ImageIcon(nearClass.getResource(src)); } catch (final Throwable e) { return null; } } /** * Loads image from InputStream */ public static ImageIcon loadImage(final InputStream inputStream) { try { return new ImageIcon(ImageIO.read(inputStream)); } catch (final Throwable e) { return null; } } }