本机多IP怎么解决 同志们,如果本机有多个IP,有IPv4的、有IPv6的、有的能访问外网服务、有的只能访问局域网,这种怎么解决的? 主要是 InetAddress.getLocalHost() 拿到IP经常是错的我们现在是通过配置文件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 上网 不是用IPv4 就行么? 不能固定ip么? 获得所有ip 然后 挨个 试试行不?new serversocket().accept()返回的是一个socket对象,也就是当前连接的信息,这里面包含有一个 getRemoteAddress方法 public static ArrayList<String> getAddress(){ArrayList<String> addresses = new ArrayList<String>(); String address = ""; String os = System.getProperty("os.name"); if (os != null && os.startsWith("Windows")) { try { String command = "cmd.exe /c ipconfig /all"; Process p = Runtime.getRuntime().exec(command); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = br.readLine()) != null) { if (line.indexOf("IP Address") > 0) { int index = line.indexOf(":"); index += 2; address = line.substring(index); addresses.add(address.trim()); } System.out.println(line); } br.close(); return addresses; } catch (IOException e) { e.printStackTrace(); } } return addresses;} 求高手解决,关于web请求的一个问题 请java高手帮忙 刚学习 很多东西不懂 请教已经工作的程序员一个问题 Spring中Hibernate jdbc同时操作导致数据读取不出来 咨询关于Struts2及webwork的资源占用问题的 ssh查询结果处理?? session.getAttribute(Constants.USER_KEY)的问题,急急 阻止session第三方cookie的问题(急) 一個關於hibernate,struts和jsp的整合問題 如何学习j2ee? 【那位大虾能帮我看看!JSP中关于解决乱码问题】 URLHttpConnection 问题
new serversocket().accept()返回的是一个socket对象,也就是当前连接的信息,这里面包含有一个 getRemoteAddress方法
public static ArrayList<String> getAddress(){
ArrayList<String> addresses = new ArrayList<String>(); String address = ""; String os = System.getProperty("os.name"); if (os != null && os.startsWith("Windows")) { try { String command = "cmd.exe /c ipconfig /all"; Process p = Runtime.getRuntime().exec(command); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = br.readLine()) != null) { if (line.indexOf("IP Address") > 0) { int index = line.indexOf(":"); index += 2; address = line.substring(index); addresses.add(address.trim()); } System.out.println(line); } br.close(); return addresses; } catch (IOException e) { e.printStackTrace(); } } return addresses;
}