public class MultiResource extends Object implements Resource, Iterable<Resource>, Iterator<Resource>, Serializable
Constructor and Description |
---|
MultiResource(Collection<Resource> resources)
构造
|
MultiResource(Resource... resources)
构造
|
Modifier and Type | Method and Description |
---|---|
MultiResource |
add(Resource resource)
增加资源
|
String |
getName()
获取资源名,例如文件资源的资源名为文件名
|
BufferedReader |
getReader(Charset charset)
获得Reader
|
InputStream |
getStream()
获得
InputStream |
URL |
getUrl()
获得解析后的
URL ,无对应URL的返回null |
boolean |
hasNext() |
Iterator<Resource> |
iterator() |
Resource |
next() |
byte[] |
readBytes()
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取 |
String |
readStr(Charset charset)
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取 |
String |
readUtf8Str()
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取 |
void |
remove() |
void |
reset()
重置游标
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
forEachRemaining
public MultiResource(Resource... resources)
resources
- 资源数组public MultiResource(Collection<Resource> resources)
resources
- 资源列表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 String readUtf8Str() throws IORuntimeException
Resource
readUtf8Str
in interface Resource
IORuntimeException
- 包装IOExceptionpublic byte[] readBytes() throws IORuntimeException
Resource
readBytes
in interface Resource
IORuntimeException
- 包装IOExceptionpublic void reset()
public MultiResource add(Resource resource)
resource
- 资源Copyright © 2021. All rights reserved.