📄 address.java
字号:
/* * Java Network Programming, Second Edition * Merlin Hughes, Michael Shoffner, Derek Hamner * Manning Publications Company; ISBN 188477749X * * http://nitric.com/jnp/ * * Copyright (c) 1997-1999 Merlin Hughes, Michael Shoffner, Derek Hamner; * all rights reserved; see license.txt for details. */package record;
import java.io.*;
import java.net.*;
import DNSRR;
import DNSInputStream;
public class Address extends DNSRR {
private int[] ipAddress = new int[4];
protected void decode (DNSInputStream dnsIn) throws IOException {
for (int i = 0; i < 4; ++ i)
ipAddress[i] = dnsIn.readByte ();
}
public byte[] getAddress () {
byte[] ip = new byte[4];
for (int j = 0; j < 4; ++ j)
ip[j] = (byte) ipAddress[j];
return ip;
}
public InetAddress getInetAddress () throws UnknownHostException {
return InetAddress.getByName (toByteString ());
}
private String toByteString () {
return ipAddress[0] + "." + ipAddress[1] + "." +
ipAddress[2] + "." + ipAddress[3];
}
public String toString () {
return getRRName () + "\tinternet address = " + toByteString ();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -