Here you can find the source of loadImage(final String path)
Parameter | Description |
---|---|
path | the path of the file to read |
public static Image loadImage(final String path)
//package com.java2s; /******************************************************************************* * Copyright (C) 2009, 2015, Danilo Pianini and contributors * listed in the project's build.gradle or pom.xml file. * * This file is distributed under the terms of the Apache License, version 2.0 *******************************************************************************/ import java.awt.Image; import java.awt.Toolkit; import java.net.URL; public class Main { /**//from w ww . j a v a 2s . c om * This method loads an Image from the file system. * * @param path * the path of the file to read * @return the loaded image */ public static Image loadImage(final String path) { final ClassLoader loader = ClassLoader.getSystemClassLoader(); final URL fileLocation = loader.getResource(path); final Image img = Toolkit.getDefaultToolkit().getImage(fileLocation); if (img != null) { return img; } return Toolkit.getDefaultToolkit().getImage(fileLocation); } }