URIs like the following are expected in a program:
rtsp://127.0.0.1:554/live.sdp/
rtsp://127.0.0.1:554/live.sdp
rtsp://127.0.0.1:554
rtsp://127.0.0.1:554/
rtsp://127.0.0.1:554//live.sdp
In the end, I'd like to have only one clean way:
rtsp://127.0.0.1:554/live.sdp
Where scheme (rtsp://), ip (127.0.0.1), port (554) and path (live.sdp) is submitted separately. So I have to make sure that the path doesn't only contains slashes (/), doesn't start with a slash (/live.sdp), doesn't end with a slash (live.sdp/) and that the URL doesn't end with slashes (rtsp://127.0.0.1:554/) so I can add a slash between URL and path without worrying something will go wrong.
Any easy method to achieve this?
Use the UriBuilder class to parse and construct URIs. There's no need to re-invent the wheel.