java 获得 ip 地址
一般情况获得本地所有的ip地址:
try {
InetAddress address = InetAddress.getLocalHost();
System.out.println(address.getHostAddress());
String name = address.getHostName();
System.out.println(name);
InetAddress[] addresses = InetAddress.getAllByName(name);
for(int i=0;i <addresses.length;i++)
System.out.println(addresses[i].getHostAddress());
}
catch(UnknownHostException uhe) {
System.err.println( "Unable to find IP ");
}
}
try {
InetAddress address = InetAddress.getLocalHost();
System.out.println(address.getHostAddress());
String name = address.getHostName();
System.out.println(name);
InetAddress[] addresses = InetAddress.getAllByName(name);
for(int i=0;i <addresses.length;i++)
System.out.println(addresses[i].getHostAddress());
}
catch(UnknownHostException uhe) {
System.err.println( "Unable to find IP ");
}
}
但是以上方法在linux下是不行的,
相关文档:
List的用法
List包括List接口以及List接口的所有实现类。因为List接口实现了Collection接口,所以List接口拥有Collection接口提供的所有常用方法,又因为List是列表类型,所以List接口还提供了一些适合于自身的常用方法,如表1所示。
表1 List接口定义的常用方法及功能
从表1可以看出,List接口提供的适合于自身的 ......
public void sort(int[] array) {
for(int i=0; i<array.length; i++) {
boolean flag = true;
for(int j=0; j<array.length-i-1; j++) {
if(array[j]>array[j+1]) {
int tmp = ar ......
java 的去掉空格空行的例子:
String so = "haolong, hei eip, "
+"ting, " +
& ......
1. SSO需求
单点登录(Single Sign On, SSO)是企业应用集成中最常见的需求。异构系统间往往都有各自的用户管理和身份验证机制,为
避免用户在进行系统切换时频繁输入用户名和密码,因此必须要实现单点登录。
2. SSO原理
说到SSO的原理,先得说一般Web应用的身份验证原理。Web身份验证之所以能成为问题主要在于HTTP协议 ......