Class UriUtils
java.lang.Object
org.noise_planet.noisemodelling.emission.utils.UriUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisValidUri(String uriString) Validates if a string is a well-formed URI and uses an approved scheme (http, https, or file).static InputStreamopenSafeStream(String urlString) Fetches a resource as an InputStream using the modern HttpClient API.
-
Constructor Details
-
UriUtils
public UriUtils()
-
-
Method Details
-
isValidUri
Validates if a string is a well-formed URI and uses an approved scheme (http, https, or file).- Parameters:
uriString- the string to validate; can be null or empty- Returns:
trueif the string is a valid URI with an allowed scheme,falseotherwise
-
openSafeStream
Fetches a resource as an InputStream using the modern HttpClient API. This method validates the HTTP status code before returning the stream.- Parameters:
urlString- The full URL of the resource.- Returns:
- An InputStream of the response body.
- Throws:
IOException- If a network error occurs, or the server returns a non-200 code or the operation is interrupted.
-