public interface Resource
| 限定符和类型 | 方法和说明 |
|---|---|
String |
getName()
获取资源名,例如文件资源的资源名为文件名
|
BufferedReader |
getReader(Charset charset)
获得Reader
|
InputStream |
getStream()
获得
InputStream |
URL |
getUrl()
获得解析后的
URL |
byte[] |
readBytes()
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取 |
String |
readStr(Charset charset)
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取 |
default String |
readUtf8Str()
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取 |
default void |
writeTo(OutputStream out)
将资源内容写出到流,不关闭输出流,但是关闭资源流
|
String getName()
InputStream getStream()
InputStreamInputStreamdefault void writeTo(OutputStream out) throws IORuntimeException
out - 输出流IORuntimeException - IO异常BufferedReader getReader(Charset charset)
charset - 编码BufferedReaderString readStr(Charset charset) throws IORuntimeException
charset - 编码IORuntimeException - 包装IOExceptiondefault String readUtf8Str() throws IORuntimeException
IORuntimeException - 包装IOExceptionbyte[] readBytes()
throws IORuntimeException
IORuntimeException - 包装IOExceptionCopyright © 2020. All rights reserved.