private static void executeNetstat(final StringBuilder netstatInfo, final String lineSeparator) {
    List<String> cmdOptionsList = new ArrayList<>();
    cmdOptionsList.add(NETSTAT_COMMAND);
    addNetstatDefaultOptions(cmdOptionsList);

    if (logger.isDebugEnabled()) {
      logger.debug("NetstatFunction executing {}", cmdOptionsList);
    }

    ProcessBuilder processBuilder = new ProcessBuilder(cmdOptionsList);
    Process netstat = null;
    InputStreamReader inputStreamReader = null;
    BufferedReader breader = null;
    try {
      netstat = processBuilder.start();

      InputStream is = netstat.getInputStream();
      inputStreamReader = new InputStreamReader(is);
      breader = new BufferedReader(inputStreamReader);
      String line;

      while ((line = breader.readLine()) != null) {
        netstatInfo.append(line).append(lineSeparator);
      }
    } catch (IOException e) {
      // TODO: change this to keep the full stack trace
      netstatInfo.append(CliStrings.format(CliStrings.NETSTAT__MSG__COULD_NOT_EXECUTE_0_REASON_1,
          NETSTAT_COMMAND, e.getMessage()));
    } finally {
      netstatInfo.append(lineSeparator); // additional new line
      releaseResources(netstat, inputStreamReader, breader);
    }
  }
Executes 'netstat' OS command & returns the result as compressed bytes.

@since GemFire 7.0
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/functions/NetstatFunction.java