Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Java have a constants defined for common port numbers?

Tags:

java

Is there a class that has defined constants for common port numbers like 80, 443, 21?

The only way right now I found is using getDefaultPort on URL that has a http, https or ftp schema, but it looks excessive to just get a constant.

I'm asking because I don't want to throw a bunch of magic numbers around the code and I assume there should be a place with those constants somewhere (e.g. we have one for UTF8 now).

like image 642
Krzysztof Krasoń Avatar asked Apr 19 '18 20:04

Krzysztof Krasoń


1 Answers

Not that I know of, but I am curious too. That would be nice. I know this is not an "answer," but in case you wanted to create your own, here is a table that I use (I would have put it in a comment, but I can't paste photos):

enter image description here

like image 126
Jabari Dash Avatar answered Sep 30 '22 16:09

Jabari Dash