|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.core.io.AbstractResource
org.springframework.core.io.ByteArrayResource
public class ByteArrayResource
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,
MimeMessageHelper.addAttachment(String, InputStreamSource)| Constructor Summary | |
|---|---|
ByteArrayResource(byte[] byteArray)
Create a new ByteArrayResource. |
|
ByteArrayResource(byte[] byteArray,
String description)
Create a new ByteArrayResource. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class org.springframework.core.io.AbstractResource |
|---|
createRelative, getFile, getFileForLastModifiedCheck, getFilename, getURI, getURL, isOpen, isReadable, lastModified, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ByteArrayResource(byte[] byteArray)
byteArray - the byte array to wrap
public ByteArrayResource(byte[] byteArray,
String description)
byteArray - the byte array to wrapdescription - where the byte array comes from| Method Detail |
|---|
public final byte[] getByteArray()
public boolean exists()
true.
exists in interface Resourceexists in class AbstractResource
public InputStream getInputStream()
throws IOException
IOException - if the stream could not be openedByteArrayInputStreampublic String getDescription()
Object.toString()public boolean equals(Object obj)
equals in class AbstractResourceArrays.equals(byte[], byte[])public int hashCode()
hashCode in class AbstractResourceResource.getDescription()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||