how can I convert IPv4 to four several integers.?
Here is some example:
This is an input: 158.195.16.154
And I want output like this:
int a=158;
int b=195;
int c=16;
int d=154;
Thx for the answers.
how can I convert IPv4 to four several integers.?
Here is some example:
This is an input: 158.195.16.154
And I want output like this:
int a=158;
int b=195;
int c=16;
int d=154;
Thx for the answers.
String ip = "158.195.16.154";
String[] tokens = ip.split("\\.");
int[] numbers = new int[tokens.lenght];
for (int i = 0; i<tokens.lenght; i++) numbers[i] = Integer.parseInt(tokens[i]);