Java ip address to grow integer method, java integer

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.