public class ResourceLoader
extends java.lang.Object
AlgorithmPlugin
more precisely from the
plugin JAR.
getResource(String)
to get an URL of the resource file or use getResourceAsStream(String)
to get an input stream that could be used to read the file directly.
MyPluginProject - src - main MyPlugin.java - resources langFile.txtTo read the resource file "langFile.txt" you have to specify the entire path meaning
main/resources/langFile.txt
.
You can derive the path from the package structure of the source folder.Constructor and Description |
---|
ResourceLoader(java.lang.ClassLoader clsl)
Creates a new resource loader.
|
Modifier and Type | Method and Description |
---|---|
java.net.URL |
findResource(java.lang.String name)
Finds a resource.
|
java.net.URL |
getResource(java.lang.String name)
Gets the URL of a resource file.
|
javax.swing.Icon |
getResourceAsIcon(java.lang.String name)
Gets a resource as an icon.
|
java.awt.Image |
getResourceAsImage(java.lang.String name)
Gets a resource as an image.
|
java.io.InputStream |
getResourceAsStream(java.lang.String name)
Gets an input stream of a resource file.
|
public ResourceLoader(java.lang.ClassLoader clsl) throws java.lang.IllegalArgumentException
clsl
- the class loader of the pluginjava.lang.IllegalArgumentException
- public java.net.URL getResource(java.lang.String name)
MyPluginProject - src - main MyPlugin.java - resources langFile.txtTo read the resource file "langFile.txt" you have to specify the entire path meaning
main/resources/langFile.txt
.
You can derive the path from the package structure of the source folder.name
- the resource file name as well as the entire path like main/resources/myFile.res
null
if there is no resource with the specified namepublic java.io.InputStream getResourceAsStream(java.lang.String name)
MyPluginProject - src - main MyPlugin.java - resources langFile.txtTo read the resource file "langFile.txt" you have to specify the entire path meaning
main/resources/langFile.txt
.
You can derive the path from the package structure of the source folder.name
- the resource file name as well as the entire path like main/resources/myFile.res
null
if there is no resource with the specified namepublic java.net.URL findResource(java.lang.String name)
name
- the name of the resourcenull
if the resource could not be foundpublic javax.swing.Icon getResourceAsIcon(java.lang.String name)
MyPluginProject - src - main MyPlugin.java - resources myIcon.pngTo read the icon "myIcon.png" you have to specify the entire path meaning
main/resources/myIcon.png
.
You can derive the path from the package structure of the source folder.name
- the name of the resourcenull
if the resource could not be loadedpublic java.awt.Image getResourceAsImage(java.lang.String name)
MyPluginProject - src - main MyPlugin.java - resources myImage.pngTo read the image "myImage.png" you have to specify the entire path meaning
main/resources/myImage.png
.
You can derive the path from the package structure of the source folder.name
- the name of the resourcenull
if the resource could not be loaded