> I am just trying to read a property file but would like to know if
> getProperty would return by searching ignorecase; if not how to
> For example
> in my code
> prop.getProperty( "db2.server" ) returns 184.108.40.206
> prop.getProperty( "DB2.server" ) returns null
> while i would like to return 220.127.116.11
> in my property file entry is as below
> db2.server = 18.104.22.168
The easy answer is that properties are case sensitive, so know and use
the correct case.
Properties objects are Maps where the keys and values are all supposed
to be Strings. Java Strings are case-sensitive, so you won't get what
you want without some fiddling. You will have to either add extra
entries to your Properties object or replace existing ones with
differently capitalized versions.
You could also create a case-insensitive string class, with suitable
hashCode and equals methods, and construct a HashMap with keys of your
new class corresponding to values from the original properties. You
would then need to look them up with the use of instances of your
case-insensitive string class, but you could hide that behind a method
that accepted regular Strings. This is a good, general solution to the
problem, but I'm still not convinced that the problem is one that you
need to solve.