Java BufferedImage Load loadImage(String filename)

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

Description

Loads the given file location as a buffered image Returns null if the image is not found

License

Apache License

Parameter

Parameter Description
filename the location of the image

Return

specified image or null

Declaration

public static BufferedImage loadImage(String filename) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.awt.image.BufferedImage;

public class Main {
    /**/*from   w ww.  j  a v a 2 s.c  o m*/
     * Loads the given file location as a buffered image
     * Returns null if the image is not found
     *
     * @param filename the location of the image
     * @return specified image or null
     **/
    public static BufferedImage loadImage(String filename) {
        BufferedImage img = null;
        try {
            return ImageIO.read(new File(filename));
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. loadImage(final URL urlToImage)
  2. loadImage(Image image)
  3. loadImage(InputStream inputStream)
  4. loadImage(Object whoOrders, String name)
  5. loadImage(String classRelativeFile)
  6. loadImage(String fileName)
  7. loadImage(String fileName, Component c)
  8. loadImage(String fileName, Component component)
  9. loadImage(String filePath)