public interface Resource
Modifier and Type | Method and Description |
---|---|
boolean |
exists() |
String |
getPath()
Returns the normalized, ResourceAccessor-relative path for this resource.
|
URI |
getUri()
Returns a unique and complete identifier for this resource.
|
boolean |
isWritable()
Return true if the resource can be written to
|
InputStream |
openInputStream()
Opens an input stream to read from this resource.
|
default OutputStream |
openOutputStream(boolean createIfNeeded)
Deprecated.
|
OutputStream |
openOutputStream(OpenOptions openOptions)
Opens an output stream given the passed
OpenOptions . |
Resource |
resolve(String other)
Resolve the given path against this resource.
|
Resource |
resolveSibling(String other)
Resolves the given path against this resource's parent path.
|
String getPath()
getUri()
This should always use `/` for separators
This should not include any sort of protocol or prefixes
This should not have a leading /.
This should have any relative paths smoothed out -- return "path/to/resource" not "path/from/../to/resource".InputStream openInputStream() throws IOException
IOException
- if there is an error reading from the resource, including if the resource does not exist or cannot be read.boolean isWritable()
boolean exists()
Resource resolve(String other)
Resource resolveSibling(String other)
OutputStream openOutputStream(OpenOptions openOptions) throws IOException
OpenOptions
.
Cannot pass a null OpenOptions valueIOException
@Deprecated default OutputStream openOutputStream(boolean createIfNeeded) throws IOException
openOutputStream(OpenOptions)
OpenOptions()
settings plus the passed createIfNeeded value.IOException
URI getUri()
getPath()
because the path within the resource accessor whereas this is the a complete path to it.
For example, a file resource may return a path of my/file.txt
and a uri of file:/tmp/project/liquibase/my/file.txt
for a resource accessor using file:/tmp/project/liquibase
as a root
Copyright © 2023 Liquibase.org. All rights reserved.