Package fish.payara.deployment.util
Class URIUtils
- java.lang.Object
-
- fish.payara.deployment.util.URIUtils
-
public final class URIUtils extends Object
General URI manipulation utilities.- Author:
- avpinchuk
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FileconvertToFile(URI uri)Downloadsurito a temporary file.static booleanexists(URI uri)Tests whether resource represented byuriexists.static booleanhasFileScheme(URI uri)Tests whetherurihas thefilescheme.static InputStreamopenStream(URI uri)Opens a connection to theuriand returns anInputStreamfor reading from that connection.
-
-
-
Method Detail
-
openStream
public static InputStream openStream(URI uri) throws IOException
Opens a connection to theuriand returns anInputStreamfor reading from that connection. Ifurirepresents an HTTP(S) resource and contains the user info part, set the Authorization header with Basic authentication credentials.- Parameters:
uri- theURIto returnsInputStreamfrom.- Returns:
- An input stream for reading from the
URI. - Throws:
IOException- if an I/O exception occurs.ClassCastException- if theuriis not a file and does not represent HTTP(S) resource.
-
convertToFile
public static File convertToFile(URI uri) throws IOException
Downloadsurito a temporary file.- Parameters:
uri- the URI to download.- Returns:
- The temporary file.
- Throws:
IOException- if an I/O exception occurs.ClassCastException- if theuriis not a file and does not represent HTTP(S) resource.
-
exists
public static boolean exists(URI uri) throws IOException
Tests whether resource represented byuriexists.- Parameters:
uri- the URI to test.- Returns:
trueif a resource exists;falseotherwise.- Throws:
IOException- if an I/O error occurs.ClassCastException- if theuriis not a file and does not represent HTTP(S) resource.
-
hasFileScheme
public static boolean hasFileScheme(URI uri)
Tests whetherurihas thefilescheme.- Parameters:
uri- the URI to test.- Returns:
trueifurihas thefilescheme;falseotherwise.
-
-