Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.StringTokenizer;

public class Main {
    public static int stringIPtoInt(String ip) {
        StringTokenizer ipTokens = new StringTokenizer(ip, ".");
        int ipArray[] = new int[4];
        ipArray[0] = Integer.parseInt(ipTokens.nextToken());
        ipArray[1] = Integer.parseInt(ipTokens.nextToken());
        ipArray[2] = Integer.parseInt(ipTokens.nextToken());
        ipArray[3] = Integer.parseInt(ipTokens.nextToken());

        return (ipArray[0] << 24) + (ipArray[1] << 16) + (ipArray[2] << 8) + ipArray[3];
    }
}