public class ByteArrayResource extends AbstractResource
Resource implementation for a given byte array.
Creates a ByteArrayInputStreams for 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.
ByteArrayInputStream,
InputStreamResource,
org.springframework.mail.javamail.MimeMessageHelper#addAttachment(String, InputStreamSource)| 构造器和说明 |
|---|
ByteArrayResource(byte[] byteArray)
Create a new ByteArrayResource.
|
ByteArrayResource(byte[] byteArray,
String description)
Create a new ByteArrayResource.
|
| 限定符和类型 | 方法和说明 |
|---|---|
long |
contentLength()
This implementation returns the length of the underlying byte array.
|
boolean |
equals(Object obj)
This implementation compares the underlying byte array.
|
boolean |
exists()
This implementation always returns
true. |
byte[] |
getByteArray()
Return the underlying byte array.
|
String |
getDescription()
This implementation returns the passed-in description, if any.
|
InputStream |
getInputStream()
This implementation returns a ByteArrayInputStream for the
underlying byte array.
|
int |
hashCode()
This implementation returns the hash code based on the
underlying byte array.
|
createRelative, getFile, getFileForLastModifiedCheck, getFilename, getURI, getURL, isOpen, isReadable, lastModified, toStringpublic ByteArrayResource(byte[] byteArray)
byteArray - the byte array to wrappublic ByteArrayResource(byte[] byteArray,
String description)
byteArray - the byte array to wrapdescription - where the byte array comes frompublic final byte[] getByteArray()
public boolean exists()
true.exists 在接口中 Resourceexists 在类中 AbstractResourcepublic long contentLength()
contentLength 在接口中 ResourcecontentLength 在类中 AbstractResourceInputStreamSource.getInputStream()public InputStream getInputStream() throws IOException
null)IOException - if the stream could not be opened
·ByteArrayInputStreampublic String getDescription()
Object.toString()public boolean equals(Object obj)
equals 在类中 AbstractResourceArrays.equals(byte[], byte[])public int hashCode()
hashCode 在类中 AbstractResourceResource.getDescription()Copyright © 2018 jretty-org. All rights reserved.