Java BufferedImage Load loadImage(String fileName)

Here you can find the source of loadImage(String fileName)

Description

Carga una imagen y retorna una instancia de la misma.

License

Open Source License

Declaration

public static Image loadImage(String fileName) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Image;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;

public class Main {
    /**/*from  ww w . j a  v a  2 s.  c  o  m*/
     * Carga una imagen y retorna una instancia de la misma. Si hay algun
     * problema al leer el archivo lanza una excepcion.
     */
    public static Image loadImage(String fileName) throws IOException {
        InputStream stream = ClassLoader.getSystemResourceAsStream(fileName);
        if (stream == null) {
            return ImageIO.read(new File(fileName));
        } else {
            return ImageIO.read(stream);
        }
    }
}

Related

  1. loadImage(Image image)
  2. loadImage(InputStream inputStream)
  3. loadImage(Object whoOrders, String name)
  4. loadImage(String classRelativeFile)
  5. loadImage(String filename)
  6. loadImage(String fileName, Component c)
  7. loadImage(String fileName, Component component)
  8. loadImage(String filePath)
  9. loadImage(String i, int x, int imageWidth, int imageHeight)