org.springframework.core.io
public class: ByteArrayResource [javadoc |
source]
java.lang.Object
org.springframework.core.io.AbstractResource
org.springframework.core.io.ByteArrayResource
All Implemented Interfaces:
Resource
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.
| Methods from org.springframework.core.io.AbstractResource: |
|---|
|
createRelative, equals, exists, getFile, getFileForLastModifiedCheck, getFilename, getURI, getURL, hashCode, isOpen, isReadable, lastModified, toString |
| Method from org.springframework.core.io.ByteArrayResource Detail: |
public boolean equals(Object obj) {
return (obj == this ||
(obj instanceof ByteArrayResource && Arrays.equals(((ByteArrayResource) obj).byteArray, this.byteArray)));
}
This implementation compares the underlying byte array. |
public boolean exists() {
return true;
}
This implementation always returns true. |
public final byte[] getByteArray() {
return this.byteArray;
}
Return the underlying byte array. |
public String getDescription() {
return this.description;
}
This implementation returns the passed-in description, if any. |
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(this.byteArray);
}
This implementation returns a ByteArrayInputStream for the
underlying byte array. |
public int hashCode() {
return (byte[].class.hashCode() * 29 * this.byteArray.length);
}
This implementation returns the hash code based on the
underlying byte array. |