Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
ANT task to process properties-files into static class

ANT task to process properties-files into static class

2007-01-03       - By Keith Hatton
Reply:     <<     11     12     13  

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@(protected)]
Sent: 02 January 2007 21:42
To: user@(protected)
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@(protected)
For additional commands, e-mail: user-help@(protected)


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.