alykins
12-07-2011, 12:55 AM
I have the following
public class getIP {
public String getMyIP(String args)
{
String _rtnString = "";
String[] ValidateThis = null;
int[] octets = null;
String spliton = ".";
ValidateThis = args.split(spliton);
if(ValidateThis[4] != "") _rtnString = "Invalid IP!";
else {
try{
for (int i=0; i<4; i++) {
octets[i] = Integer.parseInt(ValidateThis[i]);
}
_rtnString = args;
}
catch(Exception ex){
_rtnString = "Invalid IP!";
}
}
return _rtnString;
}
}
but my "intelli-sense" is throwing a warning @ line
octets[i] = Integer.parseInt(ValidateThis[i]);
"octets can only be null at this location"
? why
*for reference: I know there are better ways to validate IP's but since it is such a simple thing to do "the long way" and it forces one to use different techniques I am using it to play with android OS dev... normally I would figure out Java's equivalent to C# IPAddress.AddressFamily.InterNetwork
public class getIP {
public String getMyIP(String args)
{
String _rtnString = "";
String[] ValidateThis = null;
int[] octets = null;
String spliton = ".";
ValidateThis = args.split(spliton);
if(ValidateThis[4] != "") _rtnString = "Invalid IP!";
else {
try{
for (int i=0; i<4; i++) {
octets[i] = Integer.parseInt(ValidateThis[i]);
}
_rtnString = args;
}
catch(Exception ex){
_rtnString = "Invalid IP!";
}
}
return _rtnString;
}
}
but my "intelli-sense" is throwing a warning @ line
octets[i] = Integer.parseInt(ValidateThis[i]);
"octets can only be null at this location"
? why
*for reference: I know there are better ways to validate IP's but since it is such a simple thing to do "the long way" and it forces one to use different techniques I am using it to play with android OS dev... normally I would figure out Java's equivalent to C# IPAddress.AddressFamily.InterNetwork