org.xbill.DNS.Address.toByteArray()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中org.xbill.DNS.Address.toByteArray()方法的一些代码示例,展示了Address.toByteArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.toByteArray()方法的具体详情如下:
包路径:org.xbill.DNS.Address
类名称:Address
方法名:toByteArray

Address.toByteArray介绍

暂无

代码示例

代码示例来源:origin: tiandawu/IotXmpp

/**
 * Determines if a string contains a valid IP address.
 * @param s The string
 * @return Whether the string contains a valid IP address
 */
public static boolean
isDottedQuad(String s) {
  byte [] address = Address.toByteArray(s, IPv4);
  return (address != null);
}

代码示例来源:origin: dnsjava/dnsjava

/**
 * Determines if a string contains a valid IP address.
 * @param s The string
 * @return Whether the string contains a valid IP address
 */
public static boolean
isDottedQuad(String s) {
  byte [] address = Address.toByteArray(s, IPv4);
  return (address != null);
}

代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi

/**
 * Determines if a string contains a valid IP address.
 * @param s The string
 * @return Whether the string contains a valid IP address
 */
public static boolean
isDottedQuad(String s) {
  byte [] address = Address.toByteArray(s, IPv4);
  return (address != null);
}

代码示例来源:origin: org.littleshoot/dnsjava

/**
 * Determines if a string contains a valid IP address.
 * @param s The string
 * @return Whether the string contains a valid IP address
 */
public static boolean
isDottedQuad(String s) {
  byte [] address = Address.toByteArray(s, IPv4);
  return (address != null);
}

代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi

/**
 * Convert a string containing an IP address to an array of 4 or 16 integers.
 * @param s The address, in text format.
 * @param family The address family.
 * @return The address
 */
public static int []
toArray(String s, int family) {
  byte [] byteArray = toByteArray(s, family);
  if (byteArray == null)
    return null;
  int [] intArray = new int[byteArray.length];
  for (int i = 0; i < byteArray.length; i++)
    intArray[i] = byteArray[i] & 0xFF;
  return intArray;
}

代码示例来源:origin: tiandawu/IotXmpp

/**
 * Convert a string containing an IP address to an array of 4 or 16 integers.
 * @param s The address, in text format.
 * @param family The address family.
 * @return The address
 */
public static int []
toArray(String s, int family) {
  byte [] byteArray = toByteArray(s, family);
  if (byteArray == null)
    return null;
  int [] intArray = new int[byteArray.length];
  for (int i = 0; i < byteArray.length; i++)
    intArray[i] = byteArray[i] & 0xFF;
  return intArray;
}

代码示例来源:origin: dnsjava/dnsjava

/**
 * Convert a string containing an IP address to an array of 4 or 16 integers.
 * @param s The address, in text format.
 * @param family The address family.
 * @return The address
 */
public static int []
toArray(String s, int family) {
  byte [] byteArray = toByteArray(s, family);
  if (byteArray == null)
    return null;
  int [] intArray = new int[byteArray.length];
  for (int i = 0; i < byteArray.length; i++)
    intArray[i] = byteArray[i] & 0xFF;
  return intArray;
}

代码示例来源:origin: org.littleshoot/dnsjava

/**
 * Convert a string containing an IP address to an array of 4 or 16 integers.
 * @param s The address, in text format.
 * @param family The address family.
 * @return The address
 */
public static int []
toArray(String s, int family) {
  byte [] byteArray = toByteArray(s, family);
  if (byteArray == null)
    return null;
  int [] intArray = new int[byteArray.length];
  for (int i = 0; i < byteArray.length; i++)
    intArray[i] = byteArray[i] & 0xFF;
  return intArray;
}

代码示例来源:origin: org.echocat.jomon.net/common

@Nonnull
public static byte[] toAddress(@Nonnull String ipAsString) {
  byte[] address = toByteArray(ipAsString, IPv4);
  if (address == null) {
    address = toByteArray(ipAsString, IPv6);
  }
  if (address == null) {
    throw new IllegalArgumentException(ipAsString + " is no valid ip in string format.");
  }
  return address;
}

代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi

/**
 * Converts an address from its string representation to an IP address.
 * The address can be either IPv4 or IPv6.
 * @param addr The address, in string form
 * @return The IP addresses
 * @exception UnknownHostException The address is not a valid IP address.
 */
public static InetAddress
getByAddress(String addr) throws UnknownHostException {
  byte [] bytes;
  bytes = toByteArray(addr, IPv4);
  if (bytes != null)
    return InetAddress.getByAddress(bytes);
  bytes = toByteArray(addr, IPv6);
  if (bytes != null)
    return InetAddress.getByAddress(bytes);
  throw new UnknownHostException("Invalid address: " + addr);
}

代码示例来源:origin: dnsjava/dnsjava

/**
 * Creates a reverse map name corresponding to an address contained in
 * a String.
 * @param addr The address from which to build a name.
 * @return The name corresponding to the address in the reverse map.
 * @throws UnknownHostException The string does not contain a valid address.
 */
public static Name
fromAddress(String addr) throws UnknownHostException {
  byte [] array = Address.toByteArray(addr, Address.IPv4);
  if (array == null)
    array = Address.toByteArray(addr, Address.IPv6);
  if (array == null)
    throw new UnknownHostException("Invalid IP address");
  return fromAddress(array);
}

代码示例来源:origin: tiandawu/IotXmpp

/**
 * Creates a reverse map name corresponding to an address contained in
 * a String.
 * @param addr The address from which to build a name.
 * @return The name corresponding to the address in the reverse map.
 * @throws UnknownHostException The string does not contain a valid address.
 */
public static Name
fromAddress(String addr) throws UnknownHostException {
  byte [] array = Address.toByteArray(addr, Address.IPv4);
  if (array == null)
    array = Address.toByteArray(addr, Address.IPv6);
  if (array == null)
    throw new UnknownHostException("Invalid IP address");
  return fromAddress(array);
}

代码示例来源:origin: dnsjava/dnsjava

/**
 * Converts an address from its string representation to an IP address in
 * a particular family.
 * @param addr The address, in string form
 * @param family The address family, either IPv4 or IPv6.
 * @return The IP addresses
 * @exception UnknownHostException The address is not a valid IP address in
 * the specified address family.
 */
public static InetAddress
getByAddress(String addr, int family) throws UnknownHostException {
  if (family != IPv4 && family != IPv6)
    throw new IllegalArgumentException("unknown address family");
  byte [] bytes;
  bytes = toByteArray(addr, family);
  if (bytes != null)
    return InetAddress.getByAddress(addr, bytes);
  throw new UnknownHostException("Invalid address: " + addr);
}

代码示例来源:origin: org.littleshoot/dnsjava

/**
 * Creates a reverse map name corresponding to an address contained in
 * a String.
 * @param addr The address from which to build a name.
 * @return The name corresponding to the address in the reverse map.
 * @throws UnknownHostException The string does not contain a valid address.
 */
public static Name
fromAddress(String addr) throws UnknownHostException {
  byte [] array = Address.toByteArray(addr, Address.IPv4);
  if (array == null)
    array = Address.toByteArray(addr, Address.IPv6);
  if (array == null)
    throw new UnknownHostException("Invalid IP address");
  return fromAddress(array);
}

代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi

/**
 * Creates a reverse map name corresponding to an address contained in
 * a String.
 * @param addr The address from which to build a name.
 * @return The name corresponding to the address in the reverse map.
 * @throws UnknownHostException The string does not contain a valid address.
 */
public static Name
fromAddress(String addr, int family) throws UnknownHostException {
  byte [] array = Address.toByteArray(addr, family);
  if (array == null)
    throw new UnknownHostException("Invalid IP address");
  return fromAddress(array);
}

代码示例来源:origin: tiandawu/IotXmpp

/**
 * Creates a reverse map name corresponding to an address contained in
 * a String.
 * @param addr The address from which to build a name.
 * @return The name corresponding to the address in the reverse map.
 * @throws UnknownHostException The string does not contain a valid address.
 */
public static Name
fromAddress(String addr, int family) throws UnknownHostException {
  byte [] array = Address.toByteArray(addr, family);
  if (array == null)
    throw new UnknownHostException("Invalid IP address");
  return fromAddress(array);
}

代码示例来源:origin: org.echocat.jomon.net/common

@Nonnull
public static ARecord a(@Nonnull String name, @Nonnegative long ttl, @Nonnull String ipv4) {
  return a(name, ttl, toByteArray(ipv4, IPv4));
}

代码示例来源:origin: dnsjava/dnsjava

/**
 * Creates a reverse map name corresponding to an address contained in
 * a String.
 * @param addr The address from which to build a name.
 * @return The name corresponding to the address in the reverse map.
 * @throws UnknownHostException The string does not contain a valid address.
 */
public static Name
fromAddress(String addr, int family) throws UnknownHostException {
  byte [] array = Address.toByteArray(addr, family);
  if (array == null)
    throw new UnknownHostException("Invalid IP address");
  return fromAddress(array);
}

代码示例来源:origin: org.littleshoot/dnsjava

/**
 * Creates a reverse map name corresponding to an address contained in
 * a String.
 * @param addr The address from which to build a name.
 * @return The name corresponding to the address in the reverse map.
 * @throws UnknownHostException The string does not contain a valid address.
 */
public static Name
fromAddress(String addr, int family) throws UnknownHostException {
  byte [] array = Address.toByteArray(addr, family);
  if (array == null)
    throw new UnknownHostException("Invalid IP address");
  return fromAddress(array);
}

代码示例来源:origin: dnsjava/dnsjava

/**
 * Gets the next token from a tokenizer and converts it to a byte array
 * containing an IP address.
 * @param family The address family.
 * @return The next token in the stream, as an byte array representing an IP
 * address.
 * @throws TextParseException The input was invalid or not a valid address.
 * @throws IOException An I/O error occurred.
 * @see Address
 */
public byte []
getAddressBytes(int family) throws IOException {
  String next = _getIdentifier("an address");
  byte [] bytes = Address.toByteArray(next, family);
  if (bytes == null)
    throw exception("Invalid address: " + next);
  return bytes;
}

相关文章