Parses a TCP port number from a string. @param portnum The string to parse. @return A strictly positive, validated port number. @throws NumberFormatException if the string couldn't be parsed as an integer or if the value was outside of the range allowed for TCP ports.
(final String portnum)
| 4623 | * integer or if the value was outside of the range allowed for TCP ports. |
| 4624 | */ |
| 4625 | private static int parsePortNumber(final String portnum) |
| 4626 | throws NumberFormatException { |
| 4627 | final int port = Integer.parseInt(portnum); |
| 4628 | if (port <= 0 || port > 65535) { |
| 4629 | throw new NumberFormatException(port == 0 ? "port is zero" : |
| 4630 | (port < 0 ? "port is negative: " |
| 4631 | : "port is too large: ") + port); |
| 4632 | } |
| 4633 | return port; |
| 4634 | } |
| 4635 | |
| 4636 | } |
no outgoing calls
no test coverage detected