Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » core » io » [javadoc | source]
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.

Constructor:
 public ByteArrayResource(byte[] byteArray) 
 public ByteArrayResource(byte[] byteArray,
    String description) 
    Create a new ByteArrayResource.
    Parameters:
    byteArray - the byte array to wrap
    description - where the byte array comes from
Method from org.springframework.core.io.ByteArrayResource Summary:
equals,   exists,   getByteArray,   getDescription,   getInputStream,   hashCode
Methods from org.springframework.core.io.AbstractResource:
createRelative,   equals,   exists,   getFile,   getFileForLastModifiedCheck,   getFilename,   getURI,   getURL,   hashCode,   isOpen,   isReadable,   lastModified,   toString
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.core.io.ByteArrayResource Detail:
 public boolean equals(Object obj) 
    This implementation compares the underlying byte array.
 public boolean exists() 
    This implementation always returns true.
 public final byte[] getByteArray() 
    Return the underlying byte array.
 public String getDescription() 
    This implementation returns the passed-in description, if any.
 public InputStream getInputStream() throws IOException 
    This implementation returns a ByteArrayInputStream for the underlying byte array.
 public int hashCode() 
    This implementation returns the hash code based on the underlying byte array.