public class BytesResource extends Object implements Resource, Serializable
| Constructor and Description |
|---|
BytesResource(byte[] bytes)
构造
|
BytesResource(byte[] bytes,
String name)
构造
|
| Modifier and Type | Method and Description |
|---|---|
String |
getName()
获取资源名,例如文件资源的资源名为文件名
|
InputStream |
getStream()
获得
InputStream |
URL |
getUrl()
获得解析后的
URL,无对应URL的返回null |
byte[] |
readBytes()
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取 |
String |
readStr(Charset charset)
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取 |
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 in interface ResourceInputStreampublic String readStr(Charset charset) throws IORuntimeException
ResourcereadStr in interface Resourcecharset - 编码IORuntimeException - 包装IOExceptionpublic byte[] readBytes()
throws IORuntimeException
ResourcereadBytes in interface ResourceIORuntimeException - 包装IOExceptionCopyright © 2025. All rights reserved.