Java ip address to grow integer method, java integer
Java ip address to growth integer Method
The Code is as follows:
/*** Convert the IP address to an integer * @ param ip * @ return */public static Long ip2int (String ip) {Long num = 0L; if (ip = null) {return num;} try {ip = ip. replaceAll ("[^ 0-9 \.] "," "); // remove the null character String [] ips = ip before the String. split ("\\. "); if (ips. length = 4) {num = Long. parseLong (ips [0], 10) * 256L * 256L * 256L + Long. parseLong (ips [1], 10) * 256L * 256L + Long. parseLong (ips [2], 10) * 256L + Long. parseLong (ips [3], 10); num = num >>> 0 ;}} catch (NullPointerException ex) {System. out. println (ip);} return num ;}
C # How can I convert an IP address into a growth integer ??
The IP address is a maximum of 12 digits plus three dots ..
What is the significance of this?
String ip = "192.168.1.111 ";
Ip = ip. Replace (".","");
Long ipLong = Convert. ToInt64 (ip); // remove the. Number.
MessageBox. Show (ipLong. ToString ());
Java character to integer
Public static void main (String args []) {
String strA;
StrA = "123456 ";
For (int I = 0; I <strA. length (); I ++ ){
Char getStr;
Int B;
GetStr = strA. charAt (I );
B = getStr;
System. out. println (char) (B + 1 ));
}
}
In this way, you can
Running result:
2
3
4
5
6
7