Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java convert ip to long

public long ipToLong(String ipAddress) {

	String[] ipAddressInArray = ipAddress.split(".");

	long result = 0;
	for (int i = 0; i < ipAddressInArray.length; i++) {

		int power = 3 - i;
		int ip = Integer.parseInt(ipAddressInArray[i]);
		result += ip * Math.pow(256, power);

	}

	return result;
  }
Comment

PREVIOUS NEXT
Code Example
Java :: Java Searching Using binarySearch() 
Java :: initializing list in java 
Java :: java for loop with index 
Java :: debug cxf 
Java :: MyArrayList 
Java :: MyLinkedList 
Java :: java add a list to a list 
Java :: kkkkkkkkkkkkkk 
Java :: Calendar ranges java 
Java :: how to return arraylist as array in java 
Java :: get free player inventory slots spigot 
Java :: array list vs vector 
Java :: rename action bar android 
Java :: Exception in thread "main" java.lang.NoClassDefFoundError sdkmanager 
Java :: read excel file in java and store into arraylist 
Java :: java bogosort 
Java :: Read File and Resource in JUnit Test into Stream 
Java :: Unexpected end of file in android studio activity main.xml 
Java :: types of methods in java 
Java :: hashmap put 
Java :: java list tostring 
Java :: binary search algorithm in java 
Java :: java clear scanner 
Java :: android studio SELECT * FROM table 
Java :: how to insert a 0 in an array java 
Java :: search 
Java :: multiple spinner android 
Java :: java check array for duplicates 
Java :: generate objects with for loop java 
Java :: string to char array 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =