public class IO
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.io.InputStream |
createInputStream(java.nio.file.Path path)
Creates an input stream from the given Path, which may either be
an actual (absolute) Path, or a data Path with base64 encoded data
|
static java.io.InputStream |
createInputStream(java.net.URI uri)
Creates an input stream from the given URI, which may either be
an actual (absolute) URI, or a data URI with base64 encoded data
|
static boolean |
existsUnchecked(java.net.URI uri)
Returns whether the resource that is described with the given URI
exists.
|
static java.lang.String |
extractFileName(java.net.URI uri)
Tries to extract the "file name" that is referred to with the
given URI.
|
static long |
getContentLength(java.net.URI uri)
Try to obtain the content length from the given URI.
|
static java.nio.file.Path |
getParent(java.nio.file.Path path)
Returns the path describing the parent of the given path.
|
static java.net.URI |
getParent(java.net.URI uri)
Returns the URI describing the parent of the given URI.
|
static boolean |
isDataUri(java.net.URI uri)
Returns whether the given URI is a data URI.
|
static boolean |
isDataUriString(java.lang.String uriString)
Returns whether the given string is a data URI.
|
static java.nio.file.Path |
makeAbsolute(java.nio.file.Path basePath,
java.lang.String uriString)
Convert the given URI string into an absolute path, resolving it
against the given base path if necessary
|
static java.net.URI |
makeAbsolute(java.net.URI baseUri,
java.lang.String uriString)
Convert the given URI string into an absolute URI, resolving it
against the given base URI if necessary
|
static void |
read(java.io.InputStream inputStream,
byte[] data)
Read from the given input stream, writing into the given array,
until the array is filled.
|
static byte[] |
read(java.net.URI uri)
Read the data from the given URI as a byte array.
|
static byte[] |
readDataUri(java.lang.String uriString)
Read the base 64 encoded data from the given data URI string.
|
static byte[] |
readStream(java.io.InputStream inputStream)
Reads the data from the given inputStream and returns it as
a byte array.
|
public static java.net.URI makeAbsolute(java.net.URI baseUri,
java.lang.String uriString)
throws java.io.IOException
baseUri - The base URIuriString - The URI stringjava.io.IOException - If the URI string is not validpublic static java.nio.file.Path makeAbsolute(java.nio.file.Path basePath,
java.lang.String uriString)
throws java.io.IOException
basePath - The base pathuriString - The URI stringjava.io.IOException - If the URI string is not validpublic static java.net.URI getParent(java.net.URI uri)
uri - The URIpublic static java.nio.file.Path getParent(java.nio.file.Path path)
path - The pathpublic static boolean isDataUri(java.net.URI uri)
uri - The URIpublic static boolean isDataUriString(java.lang.String uriString)
null, then false will be returned.uriString - The URI stringpublic static java.lang.String extractFileName(java.net.URI uri)
"/" slash
that appears in the string representation of the given URI. If no
file name can be extracted, then the string representation of the
URI is returned.uri - The URIpublic static boolean existsUnchecked(java.net.URI uri)
false.uri - The URIpublic static long getContentLength(java.net.URI uri)
uri - The URIpublic static java.io.InputStream createInputStream(java.net.URI uri)
throws java.io.IOException
uri - The URIjava.io.IOException - If the stream can not be openedpublic static java.io.InputStream createInputStream(java.nio.file.Path path)
throws java.io.IOException
path - The Pathjava.io.IOException - If the stream can not be openedpublic static byte[] read(java.net.URI uri)
throws java.io.IOException
uri - The URIjava.io.IOException - If an IO error occurspublic static byte[] readDataUri(java.lang.String uriString)
base64, part
of the URI string, which must have the form
data:...;base64,...uriString - The URI stringjava.lang.IllegalArgumentException - If the given string is not a valid
Base64 encoded data URI stringpublic static byte[] readStream(java.io.InputStream inputStream)
throws java.io.IOException
inputStream - The input stream to readjava.io.IOException - If an IO error occurs, or if the thread that
executes this method is interrupted.public static void read(java.io.InputStream inputStream,
byte[] data)
throws java.io.IOException
inputStream - The input streamdata - The array to write the data tojava.io.IOException - If an IO error occurs, or the end of the input
stream was encountered before the requested number of bytes have
been readCopyright © 2022. All Rights Reserved.