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.
|
OutputStream |
openOutputStream(boolean createIfNeeded)
Opens an output stream to write to this resource.
|
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(boolean createIfNeeded) throws IOException
createIfNeeded - if true, create the resource if it does not exist. If false, throw an exception if it does not existIOException - if there is an error writing to the resource, including if the resource does not exist or permission don't allow writing.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 © 2022 Liquibase.org. All rights reserved.