public class BytesResource extends Object implements Resource, Serializable
| 构造器和说明 |
|---|
BytesResource(byte[] bytes)
构造
|
BytesResource(byte[] bytes,
String name)
构造
|
| 限定符和类型 | 方法和说明 |
|---|---|
String |
getName()
获取资源名,例如文件资源的资源名为文件名
|
InputStream |
getStream()
获得
InputStream |
URL |
getUrl()
获得解析后的
URL,无对应URL的返回null |
byte[] |
readBytes()
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取 |
String |
readStr(Charset charset)
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取 |
long |
size()
获取资源大小
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetReader, isModified, readUtf8Str, writeTopublic BytesResource(byte[] bytes)
bytes - 字节数组public BytesResource(byte[] bytes,
String name)
bytes - 字节数组name - 资源名称public InputStream getStream()
ResourceInputStreamgetStream 在接口中 ResourceInputStreampublic String readStr(Charset charset) throws IORuntimeException
ResourcereadStr 在接口中 Resourcecharset - 编码IORuntimeException - 包装IOExceptionpublic byte[] readBytes()
throws IORuntimeException
ResourcereadBytes 在接口中 ResourceIORuntimeException - 包装IOExceptionCopyright © 2023. All rights reserved.