public final class PortParser extends Object
Modifier and Type | Method and Description |
---|---|
static String |
convertHostAndPortToCommaDelimitedBytes(InetAddress host,
int port)
Convert the InetAddess and port number to a comma-delimited list of byte values,
suitable for the response String from the PASV command.
|
static HostAndPort |
parseExtendedAddressHostAndPort(String parameter)
Parse the host address and port number of an extended address.
|
static HostAndPort |
parseHostAndPort(String[] parameters)
Parse a 32-bit IP address and 16-bit port number from the String[] of FTP command parameters.
|
public static HostAndPort parseExtendedAddressHostAndPort(String parameter)
The client network address can be in IPv4 format (e.g., "132.235.1.2") or IPv6 format (e.g., "1080::8:800:200C:417A"). See RFC2428 for more information.
parameter
- - the single parameter String containing the encoded host and port numberpublic static HostAndPort parseHostAndPort(String[] parameters)
parameters
- - the String[] of command parameters. It is the concatenation
of a 32-bit internet host address and a 16-bit TCP port address. This address
information is broken into 8-bit fields and the value of each field is encoded
as a separate parameter whose value is a decimal number (in character string
representation). Thus, the six parameters for the port command would be:
h1,h2,h3,h4,p1,p2
where h1 is the high order 8 bits of the internet host address, and p1 is the
high order 8 bits of the port number.AssertFailedException
- - if parameters is null or contains an insufficient number of elementsNumberFormatException
- - if one of the parameters does not contain a parsable integerpublic static String convertHostAndPortToCommaDelimitedBytes(InetAddress host, int port)
host
- - the InetAddressport
- - the port numberCopyright © 2016. All rights reserved.