Package com.xmlmind.netutil
Class ByteArrayContent
- java.lang.Object
-
- com.xmlmind.netutil.ByteArrayContent
-
- All Implemented Interfaces:
FileContent
public final class ByteArrayContent extends Object implements FileContent
Implementation ofFileContentbased on an byte array.
-
-
Field Summary
Fields Modifier and Type Field Description StringbaseNameThe basename returned bygetName().byte[]bytesThe underlying byte array.StringcontentTypeThe content type returned bygetContentType().
-
Constructor Summary
Constructors Constructor Description ByteArrayContent(byte[] bytes)Equivalent tothis(bytes, null, null).ByteArrayContent(byte[] bytes, String contentType)Equivalent tothis(bytes, contentType, null).ByteArrayContent(byte[] bytes, String contentType, String baseName)Constructs a file content object based on specified byte array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetContentType()Returns the content type of this file content object.InputStreamgetInputStream()Returns an input stream allowing the read the contents of this file content object.StringgetName()Returns the basename of this file content object.longgetSize()Returns the size in bytes of this file content object.
-
-
-
Field Detail
-
bytes
public final byte[] bytes
The underlying byte array.
-
contentType
public final String contentType
The content type returned bygetContentType(). May benull.
-
-
Constructor Detail
-
ByteArrayContent
public ByteArrayContent(byte[] bytes)
Equivalent tothis(bytes, null, null).
-
ByteArrayContent
public ByteArrayContent(byte[] bytes, String contentType)Equivalent tothis(bytes, contentType, null).
-
ByteArrayContent
public ByteArrayContent(byte[] bytes, String contentType, String baseName)Constructs a file content object based on specified byte array.- Parameters:
bytes- the underlying byte arraycontentType- the content type associated to the contents of the byte array. May benull.baseName- a basename for the contents of the byte array. May benull.
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:FileContentReturns the basename of this file content object. May returnnullif not applicable.- Specified by:
getNamein interfaceFileContent
-
getContentType
public String getContentType()
Description copied from interface:FileContentReturns the content type of this file content object. May returnnullif unknown.- Specified by:
getContentTypein interfaceFileContent
-
getSize
public long getSize()
Description copied from interface:FileContentReturns the size in bytes of this file content object.- Specified by:
getSizein interfaceFileContent
-
getInputStream
public InputStream getInputStream()
Description copied from interface:FileContentReturns an input stream allowing the read the contents of this file content object.- Specified by:
getInputStreamin interfaceFileContent
-
-