本文整理汇总了Java中java.net.UnknownHostException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java UnknownHostException.getMessage方法的具体用法?Java UnknownHostException.getMessage怎么用?Java UnknownHostException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.UnknownHostException
的用法示例。
在下文中一共展示了UnknownHostException.getMessage方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: submit
import java.net.UnknownHostException; //导入方法依赖的package包/类
@Override
public <T extends Queueable> void submit(T bean, String submitQueue) throws EventException {
//Prepare the bean for submission
bean.setStatus(Status.SUBMITTED);
try {
if (bean.getHostName() == null) {
String localhostName = InetAddress.getLocalHost().getHostName();
logger.trace("Hostname on received bean not set. Now set to '"+localhostName+"'.");
bean.setHostName(localhostName);
}
} catch (UnknownHostException ex) {
throw new EventException("Failed to set hostname on bean. " + ex.getMessage());
}
//Create a submitter and submit the bean
ISubmitter<T> submitter = eventService.createSubmitter(uri, submitQueue);
submitter.submit(bean);
submitter.disconnect();
}
示例2: createMessageChannel
import java.net.UnknownHostException; //导入方法依赖的package包/类
public synchronized MessageChannel createMessageChannel(InetAddress host, int port)
throws IOException {
try {
String key = MessageChannel.getKey(host, port, "TLS");
if (messageChannels.get(key) != null) {
return (TLSMessageChannel) this.messageChannels.get(key);
} else {
TLSMessageChannel retval = new TLSMessageChannel(host, port, sipStack, this);
this.messageChannels.put(key, retval);
retval.isCached = true;
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug("key " + key);
logger.logDebug("Creating " + retval);
}
return retval;
}
} catch (UnknownHostException ex) {
throw new IOException(ex.getMessage());
}
}
示例3: createMessageChannel
import java.net.UnknownHostException; //导入方法依赖的package包/类
public synchronized MessageChannel createMessageChannel(InetAddress host, int port)
throws IOException {
try {
String key = MessageChannel.getKey(host, port, "TCP");
if (messageChannels.get(key) != null) {
return (TCPMessageChannel) this.messageChannels.get(key);
} else {
TCPMessageChannel retval = new TCPMessageChannel(host, port, sipStack, this);
this.messageChannels.put(key, retval);
retval.isCached = true;
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug("key " + key);
logger.logDebug("Creating " + retval);
}
return retval;
}
} catch (UnknownHostException ex) {
throw new IOException(ex.getMessage());
}
}
示例4: getHostFromLocal
import java.net.UnknownHostException; //导入方法依赖的package包/类
/**
* 从运行机器获取host
* @return
*/
public static String getHostFromLocal() {
try {
return (InetAddress.getLocalHost()).getHostName();
} catch (UnknownHostException uhe) {
String host = uhe.getMessage();
if (host != null) {
int colon = host.indexOf(Constants.COLON);
if (colon > 0) {
return host.substring(0, colon);
}
}
}
return Constants.UNKNOWN_HOST;
}
示例5: handleUnknownHostException
import java.net.UnknownHostException; //导入方法依赖的package包/类
private void handleUnknownHostException(UnknownHostException e) {
//debug log
Log.e(eTag, "Client UnknownHostException", e);
//emit event
String message = e.getMessage();
WritableMap eventParams = Arguments.createMap();
eventParams.putString("error", e.getMessage());
sendEvent(mReactContext, event_error, eventParams);
}
示例6: getRealmFromDNS
import java.net.UnknownHostException; //导入方法依赖的package包/类
/**
* Locate Kerberos realm using DNS
*
* @return the Kerberos realm
*/
private String getRealmFromDNS() throws KrbException {
// use DNS to locate Kerberos realm
String realm = null;
String hostName = null;
try {
hostName = InetAddress.getLocalHost().getCanonicalHostName();
} catch (UnknownHostException e) {
KrbException ke = new KrbException(Krb5.KRB_ERR_GENERIC,
"Unable to locate Kerberos realm: " + e.getMessage());
ke.initCause(e);
throw (ke);
}
// get the domain realm mapping from the configuration
String mapRealm = PrincipalName.mapHostToRealm(hostName);
if (mapRealm == null) {
// No match. Try search and/or domain in /etc/resolv.conf
List<String> srchlist = ResolverConfiguration.open().searchlist();
for (String domain: srchlist) {
realm = checkRealm(domain);
if (realm != null) {
break;
}
}
} else {
realm = checkRealm(mapRealm);
}
if (realm == null) {
throw new KrbException(Krb5.KRB_ERR_GENERIC,
"Unable to locate Kerberos realm");
}
return realm;
}
示例7: getLocalAddress
import java.net.UnknownHostException; //导入方法依赖的package包/类
public SocketAddress getLocalAddress() throws FluentdConnectorConfigError {
try {
return new InetSocketAddress(InetAddress.getByName(getFluentdBind()), getFluentdPort());
} catch (UnknownHostException ex) {
throw new FluentdConnectorConfigError(ex.getMessage());
}
}
示例8: CIDR
import java.net.UnknownHostException; //导入方法依赖的package包/类
public CIDR(String cidr) {
if (isValidFormatCIDR(cidr)) {
try {
calculate(cidr);
} catch (UnknownHostException e) {
throw new IllegalStateException("Unknown Host" + e.getMessage());
}
} else {
throw new IllegalArgumentException("CIDR format isn't valid");
}
}
示例9: getAddrFromBytes
import java.net.UnknownHostException; //导入方法依赖的package包/类
static InetAddress getAddrFromBytes(byte[] bytes) {
try {
return InetAddress.getByAddress(bytes);
} catch (UnknownHostException e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
}
示例10: getServerHost
import java.net.UnknownHostException; //导入方法依赖的package包/类
@Override
public InetAddress getServerHost() {
String host = getExistingProperty(PROPERTY_TASKWARRIOR_SERVER_HOST);
try {
return InetAddress.getByName(host);
} catch (UnknownHostException e) {
throw new TaskwarriorConfigurationException(e, "Cannot resolve host address '%s': %s", host, e.getMessage());
}
}
示例11: sendUDPBroadcast
import java.net.UnknownHostException; //导入方法依赖的package包/类
/**
* Послать сообщение по UDP широковещательно
*
* @param message текст посылаемого сообщения
* @param port порт получателя
*/
public static void sendUDPBroadcast(String message, int port) {
try {
sendUDPMessage(message, InetAddress.getByName("255.255.255.255"), port);
} catch (UnknownHostException ex) {
throw new ServerException("Address issues " + ex.getMessage());
}
}
示例12: getHostNameForLinux
import java.net.UnknownHostException; //导入方法依赖的package包/类
public static String getHostNameForLinux() {
try {
return (InetAddress.getLocalHost()).getHostName();
} catch (UnknownHostException uhe) {
String host = uhe.getMessage(); // host = "hostname: hostname"
if (host != null) {
int colon = host.indexOf(':');
if (colon > 0) {
return host.substring(0, colon);
}
}
return "UnknownHost";
}
}
示例13: toString
import java.net.UnknownHostException; //导入方法依赖的package包/类
@Override
public synchronized String toString() {
try {
return "[" + InetAddress.getByAddress(ipAddress) + " (" + visitStates.size() + ")]";
}
catch (UnknownHostException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
示例14: handleHostException
import java.net.UnknownHostException; //导入方法依赖的package包/类
@ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "MasterUrl is not valid")
@ExceptionHandler(UnknownHostException.class)
public String handleHostException(UnknownHostException e) {
return e.getMessage();
}