You are what you know
message.properties which is in the SAME package as the calling class
Class loaders are helpful only for resources packaged inside jar files. The are not going to help you out if you provide the wrong file path.
Balu Sadhasivam wrote:
Class loaders are helpful only for resources packaged inside jar files. The are not going to help you out if you provide the wrong file path.
Not really, it is useful for applications where you do not want to hard code file paths in your code (as long as its in CLASSPATH)
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Balu Sadhasivam wrote:
Class loaders are helpful only for resources packaged inside jar files. The are not going to help you out if you provide the wrong file path.
Not really, it is useful for applications where you do not want to hard code file paths in your code (as long as its in CLASSPATH)
So how does the class loader help you if you provide the wrong file path?
Balu Sadhasivam wrote:
So how does the class loader help you if you provide the wrong file path?
With class loader , you really don't need the file path at all. Place the property file under any directory which is in CLASSPATH and load it. if its inside package , of course you got to give "package path" and not "file path"
Package path is nothing but relative file path. If you get that wrong, you will still end up with an exception won't you?
Balu Sadhasivam wrote:
Package path is nothing but relative file path. If you get that wrong, you will still end up with an exception won't you?
Yeah , that's obvious.
I meant , loading resources with Class Loader's inputstream has advantages rather than depending on FileInputStream. Do you disagree ?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|