Package com.djrapitops.plan.storage.file
Interface Resource
-
- All Known Implementing Classes:
FileResource
,JarResource
,SpongeAssetResource
,StringCachingResource
,StringResource
public interface Resource
Interface for accessing plugin resources in jar or plugin files.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description byte[]
asBytes()
java.io.InputStream
asInputStream()
Get the resource as an InputStream.java.util.List<java.lang.String>
asLines()
Get the resource as lines.java.lang.String
asString()
Get the resource as a String with each line separated by CRLF newline characters\r\n
.default WebResource
asWebResource()
Map to a WebResource used byResourceService
APIs.java.lang.String
getResourceName()
Get the name of this Resource.static boolean
isTextResource(java.lang.String resourceName)
Check if a resource is a text based file.
-
-
-
Method Detail
-
getResourceName
java.lang.String getResourceName()
Get the name of this Resource.- Returns:
- Relative file path given to
PlanFiles
.
-
asBytes
byte[] asBytes() throws java.io.IOException
- Throws:
java.io.IOException
-
asInputStream
java.io.InputStream asInputStream() throws java.io.IOException
Get the resource as an InputStream.- Returns:
- InputStream of the resource, not closed automatically.
- Throws:
java.io.IOException
- If the resource is unavailable.
-
asLines
java.util.List<java.lang.String> asLines() throws java.io.IOException
Get the resource as lines.- Returns:
- Lines of the resource file.
- Throws:
java.io.IOException
- If the resource is unavailable.
-
asString
java.lang.String asString() throws java.io.IOException
Get the resource as a String with each line separated by CRLF newline characters\r\n
.- Returns:
- Flat string with each line separated by
\r\n
. - Throws:
java.io.IOException
- If the resource is unavailable.
-
asWebResource
default WebResource asWebResource()
Map to a WebResource used byResourceService
APIs.- Returns:
- The resource
- Throws:
java.io.UncheckedIOException
- if fails to read the file.
-
isTextResource
static boolean isTextResource(java.lang.String resourceName)
Check if a resource is a text based file.- Parameters:
resourceName
- Name of the resource- Returns:
- true if the resource is text based.
-
-