Java 8 UnknownHostException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 UnknownHostException class.

This code example shows how to use the following methods:
        ip = IPAddressUtil.textToNumericFormatV6(ipText);
 
        if (ip != null)
            return ip;
 
        throw ArgoException.raise(new UnknownHostException("[" + ipText + "]"));
    } 
 
    public static InetAddress getInetAddressFromText(String ipText) {
        byte[] ip = getDigitalFromText(ipText);
 
        try { 
            return InetAddress.getByAddress(ip);
        } catch (UnknownHostException e) {
            throw ArgoException.raise(new UnknownHostException("[" + ipText + "]"));
        } 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage
    try { 
      DNS.getIPs("name-of-an-unknown-interface"); 
      fail("Got an IP for a bogus interface"); 
    } catch (UnknownHostException e) {
      assertEquals("No such interface name-of-an-unknown-interface", 
          e.getMessage());
    } 
  } 
 
  /** 
   * Test the "default" IP addresses is the local IP addr 
   */ 
  @Test 
  public void testGetIPWithDefault() throws Exception { 
    String[] ips = DNS.getIPs(DEFAULT);
    assertEquals("Should only return 1 default IP", 1, ips.length);
    assertEquals(getLocalIPAddr().getHostAddress(), ips[0].toString());
    String ip = DNS.getDefaultIP(DEFAULT);
    assertEquals(ip, ips[0].toString());
  } 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getLocalizedMessage
                RemoteDestinationOutboundSocketBindingAddHandler.installOutboundSocketBindingService(context, bindingModel, bindingName);
            } else { 
                LocalDestinationOutboundSocketBindingAddHandler.installOutboundSocketBindingService(context, bindingModel, bindingName);
            } 
        } catch (UnknownHostException e) {
            throw new OperationFailedException(new ModelNode().set(e.getLocalizedMessage()));
        } 
    } 
 
    private void revertBindingReinstall(OperationContext context, String bindingName, ModelNode bindingModel,
                                        String attributeName, ModelNode previousValue) {
 
        context.removeService(OutboundSocketBinding.OUTBOUND_SOCKET_BINDING_BASE_SERVICE_NAME.append(bindingName));
        final ModelNode unresolvedConfig = bindingModel.clone();
        unresolvedConfig.get(attributeName).set(previousValue);
        try { 
            if (remoteDestination) {
                RemoteDestinationOutboundSocketBindingAddHandler.installOutboundSocketBindingService(context, unresolvedConfig, bindingName);
            } else { 
                LocalDestinationOutboundSocketBindingAddHandler.installOutboundSocketBindingService(context, unresolvedConfig, bindingName);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:toString
    private void handleBindingReinstall(OperationContext context, String bindingName, ModelNode bindingModel) throws OperationFailedException {
        context.removeService(SOCKET_BINDING.append(bindingName));
        try { 
            BindingAddHandler.installBindingService(context, bindingModel, bindingName, null);
        } catch (UnknownHostException e) {
            throw new OperationFailedException(new ModelNode().set(e.toString()));
        } 
    } 
 
    private void revertBindingReinstall(OperationContext context, String bindingName, ModelNode bindingModel,
                                        String attributeName, ModelNode previousValue) {
        context.removeService(SOCKET_BINDING.append(bindingName));
        ModelNode unresolvedConfig = bindingModel.clone();
        unresolvedConfig.get(attributeName).set(previousValue);
        try { 
            BindingAddHandler.installBindingService(context, unresolvedConfig, bindingName, null);
        } catch (Exception e) {
            // Bizarro, as we installed the service before 
            throw new RuntimeException(e);
        } 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
  @Override 
  public InetAddress getInetAddressByName(String host) throws UnknownHostException {
    hostSearches.add(host);
    if (!resolvedHosts.containsKey(host)) {
      throw new UnknownHostException(host);
    } 
    return resolvedHosts.get(host);
  } 
 
  @Override 
  public InetAddress getByExactName(String host) {
    return super.getByExactName(host);
  } 
   
  @Override 
  public InetAddress getByNameWithSearch(String host) {
    return super.getByNameWithSearch(host);
  } 
   
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        ip = IPAddressUtil.textToNumericFormatV6(ipText);
 
        if (ip != null)
            return ip;
 
        throw ArgoException.raise(new UnknownHostException("[" + ipText + "]"));
    } 
 
    public static InetAddress getInetAddressFromText(String ipText) {
        byte[] ip = getDigitalFromText(ipText);
 
        try { 
            return InetAddress.getByAddress(ip);
        } catch (UnknownHostException e) {
            throw ArgoException.raise(new UnknownHostException("[" + ipText + "]"));
        } 
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:printStackTrace
		try { 
			InetAddress address = InetAddress.getByName(args[0]);
			int port = Integer.parseInt(args[1]);
			send(address, port);
		} catch(UnknownHostException e) {
			e.printStackTrace();
		} 
	} 
 
	public static void send(InetAddress _addr, int _port) {
 
		try { 
			byte[] magic = { 'a', 'r', 'd', 'u', 'i', 'n', 'o' };
			DatagramPacket packet;
			packet = new DatagramPacket(magic, magic.length, _addr, _port);
 
			DatagramSocket socket = new DatagramSocket();
			socket.send(packet);
			socket.close();
			System.out.println("Packet sent.");
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:printStackTrace
			try { 
				socket = new Socket(host, port);
				socket.setKeepAlive(true);
				socket.setSoTimeout(0);
			} catch (UnknownHostException uhe) {
				uhe.printStackTrace();
				throw new WebSocketException("unknown host: " + host, uhe);
			} catch (IOException ioe) {
				ioe.printStackTrace();
				throw new WebSocketException("error while creating socket to " 
						+ url, ioe);
			} 
		} else if (scheme != null && scheme.equals("wss")) {
			if (port == -1) {
				port = 443;
			} 
			try { 
				SocketFactory factory = SSLSocketFactory.getDefault();
				socket = factory.createSocket(host, port);
			} catch (UnknownHostException uhe) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage
			InetAddress var2 = InetAddress.getLocalHost();
			return var2.getHostAddress();
		} 
		catch (UnknownHostException var3)
		{ 
			FMLLog.warning("Unable to determine local host IP, please set server-ip/hostname in the snooper config : " + var3.getMessage());
			return null; 
		} 
	} 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage
			InetAddress localInetAddress = InetAddress.getLocalHost();
			final String hostName = localInetAddress.getHostName();
			localInetAddress.getHostAddress();
			InetAddress.getByName(hostName);
		} catch (UnknownHostException uhe) {
			throw new CLIValidationException(uhe, 119, 
					CloudifyErrorMessages.HOST_VALIDATION_ABORTED_UNKNOWN_HOST.getName(), uhe.getMessage());
		} catch (SecurityException se) {
			// thrown if a security manager exists and permission to resolve the host name is denied. 
			throw new CLIValidationException(se, 120, 
					CloudifyErrorMessages.HOST_VALIDATION_ABORTED_NO_PERMISSION.getName(), se.getMessage());
		} 
	} 
 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 UnknownHostException Questions & Answers:

See Code Examples for Java 8 UnknownHostException Methods: