diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Netstat.java b/bindings/java/src/net/hyperic/sigar/cmd/Netstat.java index f0b9cea6..8e2ddb41 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Netstat.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Netstat.java @@ -6,6 +6,7 @@ import java.net.UnknownHostException; import net.hyperic.sigar.SigarException; import net.hyperic.sigar.NetConnection; import net.hyperic.sigar.NetFlags; +import net.hyperic.sigar.NetPortMap; /** * Display network connections. @@ -79,10 +80,16 @@ public class Netstat extends SigarCommandBase { return flags; } - private String formatPort(long port) { + private String formatPort(String proto, long port) { if (port == 0) { return "*"; } + if (!isNumeric) { + String service = NetPortMap.getServiceName(proto, port); + if (service != null) { + return service; + } + } return String.valueOf(port); } @@ -117,14 +124,14 @@ public class Netstat extends SigarCommandBase { for (int i=0; i