类 ByteArrayResource
- java.lang.Object
-
- com.alibaba.nacos.common.packagescan.resource.AbstractResource
-
- com.alibaba.nacos.common.packagescan.resource.ByteArrayResource
-
- 所有已实现的接口:
InputStreamSource,Resource
public class ByteArrayResource extends AbstractResource
Copy from https://github.com/spring-projects/spring-framework.git, with less modificationsResourceimplementation for a given byte array.Creates a
ByteArrayInputStreamfor the given byte array.Useful for loading content from any given byte array, without having to resort to a single-use
InputStreamResource. Particularly useful for creating mail attachments from local content, where JavaMail needs to be able to read the stream multiple times.- 从以下版本开始:
- 1.2.3
- 作者:
- Juergen Hoeller, Sam Brannen
- 另请参阅:
ByteArrayInputStream,InputStreamResource
-
-
字段概要
字段 修饰符和类型 字段 说明 private byte[]byteArrayprivate java.lang.Stringdescription
-
构造器概要
构造器 构造器 说明 ByteArrayResource(byte[] byteArray)Create a newByteArrayResource.ByteArrayResource(byte[] byteArray, java.lang.String description)Create a newByteArrayResourcewith a description.
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 longcontentLength()This implementation returns the length of the underlying byte array.booleanequals(java.lang.Object other)This implementation compares the underlying byte array.booleanexists()This implementation always returnstrue.byte[]getByteArray()Return the underlying byte array.java.lang.StringgetDescription()This implementation returns a description that includes the passed-indescription, if any.java.io.InputStreamgetInputStream()This implementation returns a ByteArrayInputStream for the underlying byte array.inthashCode()This implementation returns the hash code based on the underlying byte array.-
从类继承的方法 com.alibaba.nacos.common.packagescan.resource.AbstractResource
createRelative, getFile, getFileForLastModifiedCheck, getFilename, getUri, getUrl, isFile, isOpen, isReadable, lastModified, readableChannel, toString
-
-
-
-
构造器详细资料
-
ByteArrayResource
public ByteArrayResource(byte[] byteArray)
Create a newByteArrayResource.- 参数:
byteArray- the byte array to wrap
-
ByteArrayResource
public ByteArrayResource(byte[] byteArray, java.lang.String description)Create a newByteArrayResourcewith a description.- 参数:
byteArray- the byte array to wrapdescription- where the byte array comes from
-
-
方法详细资料
-
getByteArray
public final byte[] getByteArray()
Return the underlying byte array.
-
exists
public boolean exists()
This implementation always returnstrue.- 指定者:
exists在接口中Resource- 覆盖:
exists在类中AbstractResource
-
contentLength
public long contentLength()
This implementation returns the length of the underlying byte array.- 指定者:
contentLength在接口中Resource- 覆盖:
contentLength在类中AbstractResource- 另请参阅:
InputStreamSource.getInputStream()
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOExceptionThis implementation returns a ByteArrayInputStream for the underlying byte array.- 返回:
- the input stream for the underlying resource (must not be
null) - 抛出:
java.io.FileNotFoundException- if the underlying resource does not existjava.io.IOException- if the content stream could not be opened- 另请参阅:
ByteArrayInputStream
-
getDescription
public java.lang.String getDescription()
This implementation returns a description that includes the passed-indescription, if any.- 另请参阅:
Object.toString()
-
equals
public boolean equals(java.lang.Object other)
This implementation compares the underlying byte array.- 覆盖:
equals在类中AbstractResource- 另请参阅:
Arrays.equals(byte[], byte[])
-
hashCode
public int hashCode()
This implementation returns the hash code based on the underlying byte array.- 覆盖:
hashCode在类中AbstractResource- 另请参阅:
Resource.getDescription()
-
-