Is it possible to run this cmd line command curl ipinfo.io
within java?
I want to then pull the lat and long or "loc" from it afterwards. Thanks
You can use
var p = Runtime.getRuntime().exec("curl ipinfo.io")
And read the output like:
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
return bufferedReader.lines().collect(Collectors.toList());
} catch (IOException e) {
e.printStackTrace()
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.