| Use | Old Netscape |
| Troubleshooting | Links |
For example you could specify /com/mindprod/mypackage/mystuff.ser or /com.mindprod.mypackage.mystuff.ser or simply mystuff.ser. Don’t use Windows style filenames with \. These are not filenames, but Java resources that live along with the class files either in jars or sometimes freestanding on disk, or on the server.
In theory, getResourceAsStream will look in the local classpath, in the jar and in the directory where the class file was loaded from, though I have found in practice it is usually not that thorough. Beware, you might be getting a different copy of a file than the one in the jar you expected. In theory this should not be necessary, but test your jarred Applets with an empty classpath.
I have seen a variety of bug reports surrounding getResource and getResourceAsStream. They sometimes can’t see inside jars, see files on the server or see local files on the classpath. This is odd, since supposedly the usual ClassLoader mechanism does the looking, it has much less trouble finding class files.
Netscape 4.79 getResourceAsStream has a bug. It does not properly prepend the package name on the resource. It uses it as is.
For some Satanic reason, the folk at Netscape decided that resources must have one of a magic list of extensions. .com, .exe, .dll, .dat are not among them. Happily .jpg, .gif, .ram and .ser are. To read other extensions, you must first invoke SecurityManager.enablePrivilege( UniversalPropertyRead ).
|
|
available on the web at: |
http://mindprod.com/jgloss/getresourceasstream.html |
optional Replicator mirror
|
J:\mindprod\jgloss\getresourceasstream.html | |
![]() |
Please email your
feedback for publication,
letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear
wording, broken/redirected link reports, suggestions to improve this page or comments to
Roedy Green :
| |
| Blog | Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[50.16.166.175] |
|
| Feedback | You are visitor number 229,062. | |