code: public static BufferedImage loadImage(URL url) {
  		if( url == null )
  			return null;
  		try {
  			BufferedImage buffered = ImageIO.read(url);
  			if( buffered != null )
  				return buffered;
  			if( url.getProtocol().equals("file")) {
  				String path = URLDecoder.decode(url.getPath(), "UTF-8");
  				if( !new File(path).exists() ) {
  					System.err.println("File does not exist: "+path);
  					return null;
  				}
  			}
  		} catch (IOException ignore) {}
  		try {
  			InputStream stream = url.openStream();
  			String path = url.toString();
  			if( path.toLowerCase().endsWith("ppm")) {
  				return loadPPM(stream,null);
  			} else if( path.toLowerCase().endsWith("pgm") ) {
  				return loadPGM(stream, null);
  			}
  			stream.close();
  		} catch (IOException ignore) {}
  
  		return null;
  	}
docs: A function that load the specified image.  If anything goes wrong it returns a
  null.