- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIpChecker.java
More file actions
Latest commit
26 lines (24 loc) · 711 Bytes
/
Copy pathIpChecker.java
File metadata and controls
26 lines (24 loc) · 711 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
importjava.io.BufferedReader;
importjava.io.IOException;
importjava.io.InputStreamReader;
importjava.net.URL;
publicclassIpChecker {
publicstaticStringgetIp() throwsException {
URLwhatismyip = newURL("http://checkip.amazonaws.com");
BufferedReaderin = null;
try {
in = newBufferedReader(newInputStreamReader(
whatismyip.openStream()));
Stringip = in.readLine();
returnip;
} finally {
if (in != null) {
try {
in.close();
} catch (IOExceptione) {
e.printStackTrace();
}
}
}
}
}