Package org.miaixz.bus.core.io.resource
Class BytesResource
java.lang.Object
org.miaixz.bus.core.io.resource.BytesResource
- All Implemented Interfaces:
Serializable,Resource
基于byte[]的资源获取器
注意:此对象中getUrl方法始终返回null
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetName()获取资源名,例如文件资源的资源名为文件名获得InputStreamgetUrl()获得解析后的URL,无对应URL的返回nullbyte[]读取资源内容,读取完毕后会关闭流 关闭流并不影响下一次读取readString(Charset charset) 读取资源内容,读取完毕后会关闭流 关闭流并不影响下一次读取longsize()获取资源大小Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.miaixz.bus.core.io.resource.Resource
getReader, isModified, readString, writeTo
-
Constructor Details
-
BytesResource
public BytesResource(byte[] bytes) 构造- Parameters:
bytes- 字节数组
-
BytesResource
构造- Parameters:
bytes- 字节数组name- 资源名称
-
-
Method Details
-
getName
Description copied from interface:Resource获取资源名,例如文件资源的资源名为文件名 -
getUrl
Description copied from interface:Resource获得解析后的URL,无对应URL的返回null -
size
public long size()Description copied from interface:Resource获取资源大小 -
getStream
Description copied from interface:Resource获得InputStream- Specified by:
getStreamin interfaceResource- Returns:
InputStream
-
readString
Description copied from interface:Resource读取资源内容,读取完毕后会关闭流 关闭流并不影响下一次读取- Specified by:
readStringin interfaceResource- Parameters:
charset- 编码- Returns:
- 读取资源内容
- Throws:
InternalException- 包装IOException
-
readBytes
Description copied from interface:Resource读取资源内容,读取完毕后会关闭流 关闭流并不影响下一次读取- Specified by:
readBytesin interfaceResource- Returns:
- 读取资源内容
- Throws:
InternalException- 包装IOException
-