-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathPublicUtil.java
More file actions
36 lines (31 loc) · 812 Bytes
/
PublicUtil.java
File metadata and controls
36 lines (31 loc) · 812 Bytes
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
package com.fh.util;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* DateTime: 2016/9/17 15:39
* 功能:获取项目地址及本机IP
* 思路:
*/
public class PublicUtil {
//测试
public static void main(String[] args) {
System.out.println(getProjectPath()+"\n"+getIp());
}
//获取项目地址
public static String getProjectPath(){
String nowPath="";
nowPath=System.getProperty("user.dir")+"/";
return nowPath;
}
//获取本机IP
public static String getIp(){
String ip="";
try {
InetAddress inet=InetAddress.getLocalHost();
ip=inet.getHostAddress();
} catch ( UnknownHostException e ) {
e.printStackTrace();
}
return ip;
}
}