|
|
|
Most nontrivial applications are packaged with "resource files," which are nothing more than files used by the application for various purposes. Some examples of these resources include image (GIF, JPEG) files, message/text data, configuration/initialization information, and so on. There are several of ways to read these resources, but most of them are closely tied to the way in which the code is packaged. For example, one way will work correctly for a Java application, while another will work only for an applet. Obviously, the most desirable approach is to use a mechanism that functions correctly regardless of the packaging of the code. This is where the getResource() method in java.lang.Class is useful. It returns a URL that represents a resource, which can then be used to read the resource. |
评分
-
查看全部评分
|