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, wait
getReader, isModified, readUtf8Str, writeTo
public BytesResource(byte[] bytes)
bytes
- 字节数组public BytesResource(byte[] bytes, String name)
bytes
- 字节数组name
- 资源名称public InputStream getStream()
Resource
InputStream
getStream
in interface Resource
InputStream
public String readStr(Charset charset) throws IORuntimeException
Resource
readStr
in interface Resource
charset
- 编码IORuntimeException
- 包装IOException
public byte[] readBytes() throws IORuntimeException
Resource
readBytes
in interface Resource
IORuntimeException
- 包装IOExceptionCopyright © 2024. All rights reserved.