Java Integer Create toIntValueString(byte[] ip)

Here you can find the source of toIntValueString(byte[] ip)

Description

to Int Value String

License

Open Source License

Declaration

public static String toIntValueString(byte[] ip) 

Method Source Code

//package com.java2s;
/*//w ww  .j a v  a  2s .c  o  m
 *  PHEX - The pure-java Gnutella-servent.
 *  Copyright (C) 2001 - 2008 Phex Development Group
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 *  --- SVN Information ---
 *  $Id: AddressUtils.java 4417 2009-03-22 22:33:44Z gregork $
 */

public class Main {
    public static String toIntValueString(byte[] ip) {
        int v1 = ip[3] & 0xFF;
        int v2 = (ip[2] << 8) & 0xFF00;
        int v3 = (ip[1] << 16) & 0xFF0000;
        int v4 = (ip[0] << 24);
        long ipValue = ((long) (v4 | v3 | v2 | v1)) & 0x00000000FFFFFFFFl;
        return String.valueOf(ipValue);
    }
}

Related

  1. toIntValue(char ch)
  2. toIntValue(char ch, int defaultValue)
  3. toIntValue(final char ch)
  4. toIntValue(final Object o)
  5. toIntValue(Object number)
  6. toIntWithoutOverflow(float value)
  7. toIntWithPrefix(byte prefix, byte[] bytes)