public class CharSequenceResource extends Object implements Resource, Serializable
CharSequence
资源,字符串做为资源Constructor and Description |
---|
CharSequenceResource(CharSequence data)
构造,使用UTF8编码
|
CharSequenceResource(CharSequence data,
CharSequence name,
Charset charset)
构造
|
CharSequenceResource(CharSequence data,
String name)
构造,使用UTF8编码
|
Modifier and Type | Method and Description |
---|---|
String |
getName()
获取资源名,例如文件资源的资源名为文件名
|
BufferedReader |
getReader(Charset charset)
获得Reader
|
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
isModified, readUtf8Str, writeTo
public CharSequenceResource(CharSequence data)
data
- 资源数据public CharSequenceResource(CharSequence data, String name)
data
- 资源数据name
- 资源名称public CharSequenceResource(CharSequence data, CharSequence name, Charset charset)
data
- 资源数据name
- 资源名称charset
- 编码public InputStream getStream()
Resource
InputStream
getStream
in interface Resource
InputStream
public BufferedReader getReader(Charset charset)
Resource
getReader
in interface Resource
charset
- 编码BufferedReader
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.