public class IPAddress extends Object implements Cloneable
10010001 . 00001010 . 00100010 . 00000011
145
10 34
3
-> 145.10.34.3
bit# 0 1
7 8
31
+--+-------------------+------------------------------+
|0 |
|
|
+--+-------------------+------------------------------+
<-- network number --> <------- host number -------->
bit# 0 2
15 16
31
+--+-------------------------+------------------------+
|10|
|
|
+--+-------------------------+------------------------+
<----- network number -----> <---- host number ----->
bit# 0 3
23 24
31
+---+-----------------------------+-------------------+
|110|
|
|
+---+-----------------------------+-------------------+
<------- network number --------> <-- host number -->
限定符和类型 | 方法和说明 |
---|---|
Object |
clone()
Clone the encapsulated IP address.
|
boolean |
equals(Object another)
Compare the specified IP address to the encapsulated one.
|
int |
getIPAddress()
Return the integer representation of the IP address.
|
boolean |
isClassA()
Check if the IP address is belongs to a Class A IP address.
|
boolean |
isClassB()
Check if the IP address is belongs to a Class B IP address.
|
boolean |
isClassC()
Check if the IP address is belongs to a Class C IP address.
|
static void |
main(String[] args) |
String |
toString()
Return the string representation of the IP Address following the common decimal-dotted notation xxx.xxx.xxx.xxx.
|
public IPAddress(String ipAddressStr)
ip
- String representation of the IP address. The format of the ip's string representation must follow the
decimal-dotted notation xxx.xxx.xxx.xxx.InvalidIPAddressException
- Throws this exception when the specified string doesn't represent a valid IP
address.public IPAddress(int address)
ip
- Binary representation of the IP address.public final int getIPAddress()
public String toString()
public final boolean isClassA()
true
if the encapsulated IP address belongs to a class A IP address, otherwise
returne false
.public final boolean isClassB()
true
if the encapsulated IP address belongs to a class B IP address, otherwise
returne false
.public final boolean isClassC()
true
if the encapsulated IP address belongs to a class C IP address, otherwise
returne false
.public boolean equals(Object another)
public Object clone()
public static void main(String[] args)
Copyright © 2012 Alibaba Group. All Rights Reserved.