ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Hatton" <khat...@axiomsystems.com>
Subject RE: ANT task to process properties-files into static class
Date Wed, 03 Jan 2007 09:14:58 GMT
Two more robust solutions spring to mind:

1. You can use Properties.getProperty(String,String) to prevent your
NPE. The first string is the property name, the second is a default
value to be used when the property is not present.
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#getPro
perty(java.lang.String,%20java.lang.String)

2. Check for null values in your code - and if the property is mandatory
but missing, then throw an appropriate exception to the user.


Hope this helps,
Keith


-----Original Message-----
From: Rapthor [mailto:rapthor@lycos.de] 
Sent: 02 January 2007 21:42
To: user@ant.apache.org
Subject: Re: ANT task to process properties-files into static class




Scot P. Floess wrote:
> 
> If a property does not exist, why is a null pointer thrown?  I assume
> you mean java.util.Properties?  If so, that does not raise a null 
> pointer exception.
> 

You are right ... the NullPointerException would be thrown if I relied
on a
value read from the Properties instance. (If no matching key was present
in
the file.)
-- 
View this message in context:
http://www.nabble.com/ANT-task-to-process-properties-files-into-static-c
lass-tf2909466.html#a8131316
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message