Top Description Fields Constructors Methods
org.apache.hc.client5.http.entity.mime

public Class ByteArrayBody

extends AbstractContentBody
Class Inheritance
Imports
java.io.IOException, .OutputStream, org.apache.hc.core5.http.ContentType, org.apache.hc.core5.util.Args

Binary body part backed by a byte array.
Since
4.1
See Also
org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder

Field Summary

Modifier and TypeField and Description
private final byte[]
data

The contents of the file contained in this part.

private final String
filename

The name of the file contained in this part.

Constructor Summary

AccessConstructor and Description
public
ByteArrayBody(final byte[] data, final ContentType contentType, final String filename)

public
ByteArrayBody(final byte[]
the array of byte.
data
,
final ContentType contentType)

Public constructor that creates a new ByteArrayBody.

public
ByteArrayBody(final byte[]
The contents of the file contained in this part.
data
,
final String
The name of the file contained in this part.
filename
)

Creates a new ByteArrayBody.

Method Summary

Modifier and TypeMethod and Description
public String
getCharset()

Overrides org.apache.hc.client5.http.entity.mime.AbstractContentBody.getCharset.

Implements org.apache.hc.client5.http.entity.mime.ContentDescriptor.getCharset.

The body descriptors character set, defaulted appropriately for the MIME type.

public long
getContentLength()

Implements org.apache.hc.client5.http.entity.mime.ContentDescriptor.getContentLength.

Returns the body descriptors content-length.
public String
public void
Inherited from org.apache.hc.client5.http.entity.mime.AbstractContentBody:
getContentTypegetMediaTypegetMimeTypegetSubType

Field Detail

databack to summary
private final byte[] data

The contents of the file contained in this part.

filenameback to summary
private final String filename

The name of the file contained in this part.

Constructor Detail

ByteArrayBodyback to summary
public ByteArrayBody(final byte[] data, final ContentType contentType, final String filename)
Since
4.3
ByteArrayBodyback to summary
public ByteArrayBody(final byte[] data, final ContentType contentType)

Public constructor that creates a new ByteArrayBody.

Parameters
data:byte[]

the array of byte.

contentType:ContentType

the ContentType

Since
5.2
ByteArrayBodyback to summary
public ByteArrayBody(final byte[] data, final String filename)

Creates a new ByteArrayBody.

Parameters
data:byte[]

The contents of the file contained in this part.

filename:String

The name of the file contained in this part.

Method Detail

getCharsetback to summary
public String getCharset()

Overrides org.apache.hc.client5.http.entity.mime.AbstractContentBody.getCharset.

Implements org.apache.hc.client5.http.entity.mime.ContentDescriptor.getCharset.

Doc from org.apache.hc.client5.http.entity.mime.ContentDescriptor.getCharset.

The body descriptors character set, defaulted appropriately for the MIME type.

For TEXT types, this will be defaulted to us-ascii. For other types, when the charset parameter is missing this property will be null.

Returns:String

Character set, which has been parsed from the content-type definition. Not null for TEXT types, when unset will be set to default us-ascii. For other types, when unset, null will be returned.

Annotations
@Override
getContentLengthback to summary
public long getContentLength()

Implements org.apache.hc.client5.http.entity.mime.ContentDescriptor.getContentLength.

Doc from org.apache.hc.client5.http.entity.mime.ContentDescriptor.getContentLength.

Returns the body descriptors content-length.

Returns:long

Content length, if known, or -1, to indicate the absence of a content-length header.

Annotations
@Override
getFilenameback to summary
public String getFilename()

Implements org.apache.hc.client5.http.entity.mime.ContentBody.getFilename.

Annotations
@Override
writeToback to summary
public void writeTo(final OutputStream out) throws IOException

Implements org.apache.hc.client5.http.entity.mime.ContentBody.writeTo.

Annotations
@Override