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 InputStreamgetFileResource(String resourcePath, String fileName) Open a resource as a Stream.static ImageIconGet a gif file, make it into an ImageIcon.static ImageGet a gif file, make it into an Image.static ImageIcongetImageIcon(String fullImageName) Get a gif file, make it into an ImageIcon.static URLGet a file as a URLstatic voidtestingstatic CursormakeCursor(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-
-