Class ByteArrayBody
- java.lang.Object
 - 
- org.apache.http.entity.mime.content.AbstractContentBody
 - 
- org.apache.http.entity.mime.content.ByteArrayBody
 
 
 
- 
- All Implemented Interfaces:
 ContentBody,ContentDescriptor
public class ByteArrayBody extends AbstractContentBody
Binary body part backed by a byte array.- Since:
 - 4.1
 - See Also:
 MultipartEntityBuilder
 
- 
- 
Constructor Summary
Constructors Constructor Description ByteArrayBody(byte[] data, java.lang.String filename)Creates a new ByteArrayBody.ByteArrayBody(byte[] data, java.lang.String mimeType, java.lang.String filename)Deprecated.ByteArrayBody(byte[] data, ContentType contentType, java.lang.String filename) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetCharset()The body descriptors character set, defaulted appropriately for the MIME type.longgetContentLength()Returns the body descriptors content-length.java.lang.StringgetFilename()java.lang.StringgetTransferEncoding()Returns the body descriptors transfer encoding.voidwriteTo(java.io.OutputStream out)- 
Methods inherited from class org.apache.http.entity.mime.content.AbstractContentBody
getContentType, getMediaType, getMimeType, getSubType 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
ByteArrayBody
@Deprecated public ByteArrayBody(byte[] data, java.lang.String mimeType, java.lang.String filename)Deprecated.Creates a new ByteArrayBody.- Parameters:
 data- The contents of the file contained in this part.mimeType- The MIME type of the file contained in this part.filename- The name of the file contained in this part.
 
- 
ByteArrayBody
public ByteArrayBody(byte[] data, ContentType contentType, java.lang.String filename)- Since:
 - 4.3
 
 
- 
ByteArrayBody
public ByteArrayBody(byte[] data, java.lang.String filename)Creates a new ByteArrayBody.- Parameters:
 data- The contents of the file contained in this part.filename- The name of the file contained in this part.
 
 - 
 
- 
Method Detail
- 
getFilename
public java.lang.String getFilename()
 
- 
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOException- Throws:
 java.io.IOException
 
- 
getCharset
public java.lang.String getCharset()
Description copied from interface:ContentDescriptorThe body descriptors character set, defaulted appropriately for the MIME type.
For
TEXTtypes, this will be defaulted tous-ascii. For other types, when the charset parameter is missing this property will be null.- Specified by:
 getCharsetin interfaceContentDescriptor- Overrides:
 getCharsetin classAbstractContentBody- Returns:
 - Character set, which has been parsed from the
   content-type definition. Not null for 
TEXTtypes, when unset will be set to defaultus-ascii. For other types, when unset, null will be returned. 
 
- 
getTransferEncoding
public java.lang.String getTransferEncoding()
Description copied from interface:ContentDescriptorReturns the body descriptors transfer encoding.- Returns:
 - The transfer encoding. Must not be null, but "7bit", if no transfer-encoding was specified.
 
 
- 
getContentLength
public long getContentLength()
Description copied from interface:ContentDescriptorReturns the body descriptors content-length.- Returns:
 - Content length, if known, or -1, to indicate the absence of a content-length header.
 
 
 - 
 
 -