public class InputStreamResource extends Object implements Resource
InputStream的资源获取器
注意:此对象中getUrl方法始终返回null| Constructor and Description |
|---|
InputStreamResource(InputStream in)
构造
|
InputStreamResource(InputStream in,
String name)
构造
|
| Modifier and Type | Method and Description |
|---|---|
String |
getName()
获取资源名,例如文件资源的资源名为文件名
|
BufferedReader |
getReader(Charset charset)
获得Reader
|
InputStream |
getStream()
获得
InputStream |
URL |
getUrl()
获得解析后的
URL |
byte[] |
readBytes()
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取
|
String |
readStr(Charset charset)
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取
|
String |
readUtf8Str()
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取
|
public InputStreamResource(InputStream in)
in - InputStreampublic InputStreamResource(InputStream in, String name)
in - InputStreamname - 资源名称public InputStream getStream()
ResourceInputStreamgetStream in interface ResourceInputStreampublic BufferedReader getReader(Charset charset)
ResourcegetReader in interface Resourcecharset - 编码BufferedReaderpublic String readStr(Charset charset) throws InstrumentException
ResourcereadStr in interface Resourcecharset - 编码InstrumentException - 包装IOExceptionpublic String readUtf8Str() throws InstrumentException
ResourcereadUtf8Str in interface ResourceInstrumentException - 包装IOExceptionpublic byte[] readBytes()
throws InstrumentException
ResourcereadBytes in interface ResourceInstrumentException - 包装IOExceptionCopyright © 2020. All rights reserved.