本文整理汇总了Java中java.net.UnknownHostException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java UnknownHostException.printStackTrace方法的具体用法?Java UnknownHostException.printStackTrace怎么用?Java UnknownHostException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.UnknownHostException
的用法示例。
在下文中一共展示了UnknownHostException.printStackTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import java.net.UnknownHostException; //导入方法依赖的package包/类
@Override
public ElasticsearchAddonImpl initialize(ServiceConfig serviceConfig) {
Settings settings = Settings.builder()
.put("cluster.name", clustername)
.put("node.name", clientname)
.build();
InetAddress address = null;
try {
address = InetAddress.getByName(coordinatorUrl);
} catch (UnknownHostException e) {
e.printStackTrace();
}
return this.withClient(new PreBuiltTransportClient(settings).addTransportAddress(new InetSocketTransportAddress(address, coordinatorPort)));
}
示例2: Blowfish
import java.net.UnknownHostException; //导入方法依赖的package包/类
public Blowfish(String csKey, boolean bMixWithIpAdress)
{
try
{
if(bMixWithIpAdress)
{
InetAddress adr = InetAddress.getLocalHost();
byte ipAdress[] = adr.getAddress();
int nVal = 0;
for(int n=0; n<ipAdress.length; n++)
{
nVal *= 256;
nVal += ipAdress[n];
}
csKey += nVal;
}
}
catch (UnknownHostException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
m_csKey = csKey;
}
示例3: getDeviceIpAddress
import java.net.UnknownHostException; //导入方法依赖的package包/类
private InetAddress getDeviceIpAddress(WifiManager wifi) {
InetAddress result = null;
try {
// default to Android localhost
result = InetAddress.getByName("10.0.0.2");
// figure out our wifi address, otherwise bail
WifiInfo wifiinfo = wifi.getConnectionInfo();
int intaddr = wifiinfo.getIpAddress();
byte[] byteaddr = new byte[] { (byte) (intaddr & 0xff), (byte) (intaddr >> 8 & 0xff), (byte) (intaddr >> 16 & 0xff), (byte) (intaddr >> 24 & 0xff) };
result = InetAddress.getByAddress(byteaddr);
} catch (UnknownHostException e) {
e.printStackTrace();
Log.e(TAG, "getDeviceIpAddress Error: " + e.getMessage());
}
return result;
}
示例4: checkConnectImpl
import java.net.UnknownHostException; //导入方法依赖的package包/类
final void checkConnectImpl(String host, int port) {
Class insecure = getInsecureClass();
if (insecure != null) {
URL ctx = getClassURL(insecure);
if (ctx != null) {
try {
String fromHost = ctx.getHost();
InetAddress ia2 = InetAddress.getByName(host);
InetAddress ia3 = InetAddress.getByName(fromHost);
if (ia2.equals(ia3)) {
return;
}
} catch (UnknownHostException e) { // ignore
e.printStackTrace();
}
}
throw new SecurityException();
}
}
示例5: onConfigChanged
import java.net.UnknownHostException; //导入方法依赖的package包/类
@Override
public void onConfigChanged(OnConfigChangedEvent ev)
{
if (ev.configID.equals(MalmoMod.SOCKET_CONFIGS))
{
AddressHelper.update(MalmoMod.instance.getModSessionConfigFile());
try
{
ClientStateMachine.this.initialiseComms();
}
catch (UnknownHostException e)
{
// TODO What to do here?
e.printStackTrace();
}
ScreenHelper.update(MalmoMod.instance.getModPermanentConfigFile());
}
}
示例6: init
import java.net.UnknownHostException; //导入方法依赖的package包/类
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
String file = this.getServletContext().getRealPath(this.getInitParameter("log4j"));
//从web.xml配置读取,名字一定要和web.xml配置一致
if(file != null){
PropertyConfigurator.configure(file);
}
// Put your code here
new CrawlerServer(DefaultConfig.serverPort).start();
try {
new WebSocket(DefaultConfig.socketPort).start();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例7: localHostName
import java.net.UnknownHostException; //导入方法依赖的package包/类
public static String localHostName() {
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
e.printStackTrace();
}
return "DEFAULT_BROKER";
}
示例8: getHost
import java.net.UnknownHostException; //导入方法依赖的package包/类
public static String getHost() {
try {
InetAddress a = InetAddress.getLocalHost();
return a.getHostAddress().toUpperCase();
} catch (UnknownHostException e) {
e.printStackTrace();
return "N/A";
}
}
示例9: getDomainAddress
import java.net.UnknownHostException; //导入方法依赖的package包/类
/**
* 获取域名ip地址
* <p>需添加权限 {@code <uses-permission android:name="android.permission.INTERNET"/>}</p>
*
* @param domain 域名
* @return ip地址
*/
public static String getDomainAddress(final String domain) {
InetAddress inetAddress;
try {
inetAddress = InetAddress.getByName(domain);
return inetAddress.getHostAddress();
} catch (UnknownHostException e) {
e.printStackTrace();
return null;
}
}
示例10: initClient
import java.net.UnknownHostException; //导入方法依赖的package包/类
private static void initClient() {
try {
client = TransportClient.builder().settings(Settings.EMPTY).build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(IP), PORT));
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
示例11: init
import java.net.UnknownHostException; //导入方法依赖的package包/类
@Override
public void init()
{
try{
System.setProperty("java.net.preferIPv4Stack", "true");
ip = InetAddress.getLocalHost();
ipadd = ip.getHostAddress();
}catch (UnknownHostException e)
{
e.printStackTrace();
}
}
示例12: getLocalHost
import java.net.UnknownHostException; //导入方法依赖的package包/类
public String getLocalHost() {
// TODO Auto-generated method stub
String addr="";
try {
addr= InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return addr;
}
开发者ID:cyberheartmi9,项目名称:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代码行数:12,代码来源:Action.java
示例13: ipIntToInet4Address
import java.net.UnknownHostException; //导入方法依赖的package包/类
public static InetAddress ipIntToInet4Address(int ip) {
byte[] ipAddress = new byte[4];
writeInt(ipAddress, 0, ip);
try {
return Inet4Address.getByAddress(ipAddress);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
示例14: detectIPAddress
import java.net.UnknownHostException; //导入方法依赖的package包/类
private static String detectIPAddress() {
String ipAddress = null;
try {
if (InetAddress.getLocalHost().isAnyLocalAddress() || InetAddress.getLocalHost().isLoopbackAddress() || InetAddress.getLocalHost().isSiteLocalAddress()) {
ipAddress = InetAddress.getLoopbackAddress().getHostAddress();
} else {
ipAddress = InetAddress.getLocalHost().getHostAddress();
}
} catch (final UnknownHostException e) {
e.printStackTrace();
}
return ipAddress;
}
示例15: init
import java.net.UnknownHostException; //导入方法依赖的package包/类
@Override
public void init()
{
System.setProperty("java.net.preferIPv4Stack", "true");
try{
ip = InetAddress.getLocalHost();
ipadd = ip.getHostAddress();
}catch (UnknownHostException e)
{
e.printStackTrace();
}
}