Tutorial by Examples

To load a bundled image: package com.example; public class ExampleApplication { private Image getIcon() throws IOException { URL imageURL = ExampleApplication.class.getResource("icon.png"); return ImageIO.read(imageURL); } }
To read default configuration properties: package com.example; public class ExampleApplication { private Properties getDefaults() throws IOException { Properties defaults = new Properties(); try (InputStream defaultsStream = ExampleApplication.class.getResou...
Resource with same path and name may exist in more than one JAR file on the classpath. Common cases are resources following a convention or that are part of a packaging specification. Examples for such resources are META-INF/MANIFEST.MF META-INF/beans.xml (CDI Spec) ServiceLoader properties con...
Resource loading in Java comprises the following steps: Finding the Class or ClassLoader that will find the resource. Finding the resource. Obtaining the byte stream for the resource. Reading and processing the byte stream. Closing the byte stream. The last three steps are typically accomp...

Page 1 of 1