ad5081d3
孙向锦
初始化项目
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package com.fh.util;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* 说明:IP处理
* 创建人:FH Q313596790
* 修改时间:2014年9月20日
* @version
*/
public class PublicUtil {
public static void main(String[] args) {
System.out.println("本机的ip=" + PublicUtil.getIp());
}
public static String getPorjectPath(){
String nowpath = "";
nowpath=System.getProperty("user.dir")+"/";
return nowpath;
}
/**
* 获取本机访问地址
* @return
*/
public static String getIp(){
String ip = "";
try {
InetAddress inet = InetAddress.getLocalHost();
ip = inet.getHostAddress();
//System.out.println("本机的ip=" + ip);
} catch (UnknownHostException e) {
e.printStackTrace();
}
return ip;
}
}
|