Avatar of judsonV
judsonV

asked on 

Ignoring IP's in a java properties file

I have an application that reads incoming packets from specific IP address. Testing is changing and adding IP's to the boxes and they are providing me with a list of IP's they want me to code into the app to ignore.

The existing code look like this :
if (localIP != null && localIP != "142.139.24.87" && localIP != "142.139.24.12" && (localIP.equals(WebUtil.getDevIPAddress()) || localIP.equals(WebUtil.getUaIPAddress()) || localIP.equals(WebUtil.getProdIPAddress())))

As you can see I hard coded the first two IP's they provided to me to ignore. But now they are saying there could be up to 20 IP's which would make an huge if statement. I'm normally a 'net guy and this is java app so i'm a little out of my element.

I know I could make a properties file that could contain all the ip's (they are stored as strings currently thankfully enough) and just basically in that if statement tell the app to ignore everything in that properties file.  

I have created the properties file which looks like:
# Redundant IP's in the test/UA environment as of 2011-08-10
ClientChooser.IP=149.139.24.12  
PaymentHub.IP=149.139.24.87

Now in the code how do call that and tell the app to ignore every IP in that file?

Thanks
SoftwareJSP

Avatar of undefined
Last Comment
for_yan

8/22/2022 - Mon