Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// Copyright 2011-2012 Paulo Augusto Peccin. See licence.txt distributed with this file.

import java.awt.image.BufferedImage;

import java.io.IOException;

import java.net.URL;
import javax.imageio.ImageIO;

public class Main {
    public static BufferedImage loadImage(String fileName) throws IOException {
        URL url = Thread.currentThread().getContextClassLoader().getResource(fileName);
        if (url == null)
            throw new IOException("Could not find image: " + fileName);
        return ImageIO.read(url);
    }
}