public class DNSInputStream extends ByteArrayInputStream
DNSInputStrean extends a ByteArrayInputStream and has methods to decode the data of a DNS response to an address request.
buf, count, mark, pos
Constructor and Description |
---|
DNSInputStream(byte[] data)
Constructs a new input stream for decoding DNS records.
|
DNSInputStream(byte[] data,
int off,
int len)
Constructs a DNSInputStream object from the byte array.
|
Modifier and Type | Method and Description |
---|---|
int |
readByte()
Read a byte off the input stream.
|
String |
readDomainName()
The readDomainName method is used to read an entire domain name from the
stream.
|
long |
readInt()
Read an 'int' off the input stream.
|
DNSAddressRR |
readRR()
Reads the resource record from the input stream.
|
int |
readShort()
Read a 'short' off the input stream.
|
String |
readString()
Read a 'string' off the input stream.
|
available, close, mark, markSupported, read, read, reset, skip
read
public DNSInputStream(byte[] data)
Constructs a new input stream for decoding DNS records.
data
- The array of data to pass to the base class.public DNSInputStream(byte[] data, int off, int len)
Constructs a DNSInputStream object from the byte array.
data
- byte array containing the response dataoff
- offset of the data in the byte arraylen
- length of the byte arraypublic int readByte() throws IOException
Read a byte off the input stream.
IOException
- Thrown if the end-of-file is encountered trying to read
the next byte.IOException
- if any.public int readShort() throws IOException
Read a 'short' off the input stream.
IOException
- Thrown if the end-of-file is encountered trying to read
the next short.IOException
- if any.public long readInt() throws IOException
Read an 'int' off the input stream.
IOException
- Thrown if there is an error while read.IOException
- if any.public String readString() throws IOException
Read a 'string' off the input stream.
IOException
- Thrown if there is an error while readIOException
- if any.public String readDomainName() throws IOException
The readDomainName method is used to read an entire domain name from the stream. The string returned will be the concatentation of several substrings, each substring in the record is separated by a '.'(dot). For more information see the RFC for the distributed name service.
IOException
- Thrown if an error occurs decoding the string from the
stream.IOException
- if any.public DNSAddressRR readRR() throws IOException
Reads the resource record from the input stream.
IOException
- Thrown if data does not decode to a DNSAddressRRl.IOException
- if any.Copyright © 2021. All rights reserved.