Package ucar.unidata.util
Class Resource
java.lang.Object
ucar.unidata.util.Resource
Cover for fetching files using Class.getResource().
If the application is started from a jar file, then it looks in there.
If the application is started from a class file, then it looks in the
disk file heirarchy, using directories in the classpath as root(s).
1. Filenames.
use "/" as path seperator when embedded in a string. This works on both Windows and Unix.
2. Filepath.
Use a resourcePath starting with a forward slash. getResource() then searches relative to the classpath.
otherwise it will search reletive to ucar.unidata.util, which is probably not what you want.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStream
getFileResource
(String resourcePath, String fileName) Open a resource as a Stream.static ImageIcon
Get a gif file, make it into an ImageIcon.static Image
Get a gif file, make it into an Image.static ImageIcon
getImageIcon
(String fullImageName) Get a gif file, make it into an ImageIcon.static URL
Get a file as a URLstatic void
testingstatic Cursor
makeCursor
(String name) Get a gif file, make it into a Cursor.
-
Constructor Details
-
Resource
public Resource()
-
-
Method Details
-
getIcon
Get a gif file, make it into an ImageIcon.- Parameters:
fullIconName
- full path name of gif file (use forward slashes!)errMsg
- print err message on failure- Returns:
- ImageIcon or null on failure
-
getImage
Get a gif file, make it into an Image.- Parameters:
fullImageName
- full path name of gif file (use forward slashes!)- Returns:
- Image or null on failure
-
getImageIcon
Get a gif file, make it into an ImageIcon.- Parameters:
fullImageName
- full path name of gif file (use forward slashes!)- Returns:
- Image or null on failure
-
getURL
Get a file as a URL- Parameters:
filename
- full path name of file (use forward slashes!)- Returns:
- URL or null on failure
-
makeCursor
Get a gif file, make it into a Cursor.- Parameters:
name
- full path name of gif file (use forward slashes!)- Returns:
- Cursor or null on failure
-
getFileResource
Open a resource as a Stream. First try ClassLoader.getResourceAsStream(). If that fails, try a plain old FileInputStream().- Parameters:
resourcePath
- name of file path (use forward slashes!)fileName
- name of file (use forward slashes!)- Returns:
- InputStream or null on failure
-
main
testing- Parameters:
args
-
-