Here you can find the source of long2String(final long ip)
Parameter | Description |
---|---|
ip | long value representing an IP address |
public static String long2String(final long ip)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 GigaSpaces Technologies Ltd. All rights reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.// www. ja va2s . c om ******************************************************************************/ public class Main { /** * Converts a long value representing an IP address to a standard IP address (dotted decimal format). * * @param ip * long value representing an IP address * @return A standard IP address */ public static String long2String(final long ip) { final long a = (ip & 0xff000000) >> 24; final long b = (ip & 0x00ff0000) >> 16; final long c = (ip & 0x0000ff00) >> 8; final long d = ip & 0xff; return a + "." + b + "." + c + "." + d; } }