Package android.util
Class Base64OutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- android.util.Base64OutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class Base64OutputStream extends java.io.FilterOutputStream
An OutputStream that does Base64 encoding on the data written to it, writing the resulting data to another OutputStream.
-
-
Constructor Summary
Constructors Constructor Description Base64OutputStream(java.io.OutputStream out, int options)
Performs Base64 encoding on the data written to the stream, writing the encoded data to another OutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Encodes and writes the remaining buffered bytes, adds necessary padding, and closes the output stream.void
flush()
Flushed the enclosed output stream, but does not write uncompleted 4-blocks.void
write(int theByte)
Writes the byte to the output stream after converting to/from Base64 notation.
-
-
-
Constructor Detail
-
Base64OutputStream
public Base64OutputStream(java.io.OutputStream out, int options)
Performs Base64 encoding on the data written to the stream, writing the encoded data to another OutputStream.- Parameters:
out
- the OutputStream to write the encoded data tooptions
- bit flags for controlling the encoder; see the constants in Base64
-
-
Method Detail
-
write
public void write(int theByte) throws java.io.IOException
Writes the byte to the output stream after converting to/from Base64 notation. When encoding, bytes are buffered three at a time before the output stream actually gets a write() call. When decoding, bytes are buffered four at a time.- Overrides:
write
in classjava.io.FilterOutputStream
- Parameters:
theByte
- the byte to write.- Throws:
java.io.IOException
- when unable to write data.
-
flush
public void flush() throws java.io.IOException
Flushed the enclosed output stream, but does not write uncompleted 4-blocks. To ensure consistency that only happens on close.- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- If unable to write to the output stream.
-
close
public void close() throws java.io.IOException
Encodes and writes the remaining buffered bytes, adds necessary padding, and closes the output stream. Does nothing if the stream is already closed.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- If unable to write the remaining bytes or close the stream.
-
-