Java BufferedImage Load loadResource(String file)

Here you can find the source of loadResource(String file)

Description

load Resource

License

Apache License

Declaration

public static Image loadResource(String file) 

Method Source Code


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

import java.awt.Image;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;

public class Main {
    public static Image loadResource(String file) {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        InputStream input = classLoader.getResourceAsStream(file);
        try {/*from  w w  w  .ja  va 2s.  com*/
            return ImageIO.read(input);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. loadImageFromURL(String imageURL, Component component)
  2. loadImageFromVisualgorithmJar(String imageFileName)
  3. loadImageRessource(Object source, String file)
  4. loadImages(Image[] images, Component comp)
  5. loadImagesForVVPAT(File ballotFile)