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 File
convertToFile(URI uri)
Downloadsuri
to a temporary file.static boolean
exists(URI uri)
Tests whether resource represented byuri
exists.static boolean
hasFileScheme(URI uri)
Tests whetheruri
has thefile
scheme.static InputStream
openStream(URI uri)
Opens a connection to theuri
and returns anInputStream
for reading from that connection.
-
-
-
Method Detail
-
openStream
public static InputStream openStream(URI uri) throws IOException
Opens a connection to theuri
and returns anInputStream
for reading from that connection. Ifuri
represents an HTTP(S) resource and contains the user info part, set the Authorization header with Basic authentication credentials.- Parameters:
uri
- theURI
to returnsInputStream
from.- Returns:
- An input stream for reading from the
URI
. - Throws:
IOException
- if an I/O exception occurs.ClassCastException
- if theuri
is not a file and does not represent HTTP(S) resource.
-
convertToFile
public static File convertToFile(URI uri) throws IOException
Downloadsuri
to a temporary file.- Parameters:
uri
- the URI to download.- Returns:
- The temporary file.
- Throws:
IOException
- if an I/O exception occurs.ClassCastException
- if theuri
is not a file and does not represent HTTP(S) resource.
-
exists
public static boolean exists(URI uri) throws IOException
Tests whether resource represented byuri
exists.- Parameters:
uri
- the URI to test.- Returns:
true
if a resource exists;false
otherwise.- Throws:
IOException
- if an I/O error occurs.ClassCastException
- if theuri
is not a file and does not represent HTTP(S) resource.
-
hasFileScheme
public static boolean hasFileScheme(URI uri)
Tests whetheruri
has thefile
scheme.- Parameters:
uri
- the URI to test.- Returns:
true
ifuri
has thefile
scheme;false
otherwise.
-
-