呵呵,如果出现负数,用补码就可以获得实际的值,也就是256+bytevalue,也是可以接受的.

解决方案 »

  1.   

    An instance of an InetAddress consists of an IP address and possibly its corresponding host name (depending on whether it is constructed with a host name or whether it has already done reverse host name resolution).
      

  2.   

    When four parts are specified, each is interpreted as a byte of data and assigned, from left to right, to the four bytes of an IPv4 address. When a three part address is specified, the last part is interpreted as a 16-bit quantity and placed in the right most two bytes of the network address. This makes the three part address format convenient for specifying Class B net- work addresses as 128.net.host. When a two part address is supplied, the last part is interpreted as a 24-bit quantity and placed in the right most three bytes of the network address. This makes the two part address format convenient for specifying Class A network addresses as net.host. When only one part is given, the value is stored directly in the network address without any byte rearrangement. For methods that return a textual representation as output value, the first form, i.e. a dotted-quad string, is used. 
      

  3.   

    我觉得不应该老是把ip地址看为10进制数
    对ipv4就是个32位的二进制而已,不就想通了