Java BufferedImage Load loadImage(File file)

Here you can find the source of loadImage(File file)

Description

load Image

License

Apache License

Declaration

public static BufferedImage loadImage(File file) throws IOException 

Method Source Code


//package com.java2s;
//   Licensed under the Apache License, Version 2.0 (the "License");

import javax.imageio.ImageIO;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;

public class Main {
    public static BufferedImage loadImage(File file) throws IOException {
        final FileInputStream fis = new FileInputStream(file);
        try {//w w  w. j a v a  2 s. com
            final BufferedImage bufferedImage = ImageIO.read(fis);
            if (bufferedImage == null) {
                throw new IOException("ImageIO.read returned null for " + file);
            }
            return bufferedImage;
        } finally {
            fis.close();
        }
    }
}

Related

  1. loadFromResource(String imageName, Class cls)
  2. loadFromURL(String url)
  3. loadImage(byte[] data)
  4. loadImage(ClassLoader classLoader, String path)
  5. loadImage(File file)
  6. loadImage(File file)
  7. loadImage(File file)
  8. loadImage(File pFile)
  9. loadImage(final byte[] imageData)