Java code for validating ip address