public abstract class BodyWriter extends Object
UploadService.BUFFER_SIZE and to clear everything when not needed to prevent memory leaks| Modifier and Type | Class and Description |
|---|---|
static interface |
BodyWriter.OnStreamWriteListener
Receives the stream write progress and has the ability to cancel it.
|
| Constructor and Description |
|---|
BodyWriter() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
flush()
Ensures the bytes written to the body are all transmitted to the server and clears
the local buffer.
|
abstract void |
write(byte[] bytes)
Write a byte array into the request body.
|
abstract void |
write(byte[] bytes,
int lengthToWriteFromStart)
Write a portion of a byte array into the request body.
|
void |
writeStream(InputStream stream,
BodyWriter.OnStreamWriteListener listener)
Writes an input stream to the request body.
|
public final void writeStream(InputStream stream, BodyWriter.OnStreamWriteListener listener) throws IOException
stream - input stream from which to readlistener - listener which gets notified when bytes are written and which controls if
the transfer should continueIOException - if an I/O error occurspublic abstract void write(byte[] bytes)
throws IOException
bytes - array with the bytes to writeIOException - if an error occurs while writingpublic abstract void write(byte[] bytes,
int lengthToWriteFromStart)
throws IOException
bytes - array with the bytes to writelengthToWriteFromStart - how many bytes to write, starting from the first one in
the arrayIOException - if an error occurs while writingpublic abstract void flush()
throws IOException
IOException - if an error occurs while flushing the buffer