Class UriUtils
- java.lang.Object
-
- org.noise_planet.noisemodelling.emission.utils.UriUtils
-
public class UriUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description UriUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.
-
-
-
Method Detail
-
isValidUri
public static boolean isValidUri(String uriString)
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
public static InputStream openSafeStream(String urlString) throws IOException
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.
-
-