org.springframework.core.io

Class ByteArrayResource

    • Constructor Detail

      • ByteArrayResource

        public ByteArrayResource(byte[] byteArray)
        Create a new ByteArrayResource.
        Parameters:
        byteArray - the byte array to wrap
      • ByteArrayResource

        public ByteArrayResource(byte[] byteArray,
                                 @Nullable
                                 java.lang.String description)
        Create a new ByteArrayResource with a description.
        Parameters:
        byteArray - the byte array to wrap
        description - where the byte array comes from
    • Method Detail

      • getByteArray

        public final byte[] getByteArray()
        Return the underlying byte array.
      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        This implementation returns a ByteArrayInputStream for the underlying byte array.
        Returns:
        the input stream for the underlying resource (must not be null)
        Throws:
        java.io.FileNotFoundException - if the underlying resource doesn't exist
        java.io.IOException - if the content stream could not be opened
        See Also:
        ByteArrayInputStream
      • getDescription

        public java.lang.String getDescription()
        This implementation returns a description that includes the passed-in description, if any.
        See Also:
        Object.toString()
      • equals

        public boolean equals(java.lang.Object other)
        This implementation compares the underlying byte array.
        Overrides:
        equals in class AbstractResource
        See Also:
        Arrays.equals(byte[], byte[])