The answer is yes, depending on your operating system.
You need to find the appropriate command, for example on mac osx, it lsof -i , then use Runtime to execute it and analyze the output.
Here is some basic code that would do this:
Process p = Runtime.getRuntime().exec(new String[] { "lsof", "-i" }); InputStream commandOutput = p.getInputStream();
source share