public class TLVOutputStream
extends java.io.OutputStream
writeTag(int),
and then:
writeValue(byte[])
(which will cause the length and that value to be written),
write calls to write
the value and terminate with a writeValueEnd()
(which will cause the length and value to be computed and written).
| Constructor and Description |
|---|
TLVOutputStream(java.io.OutputStream outputStream)
Constructs a TLV output-stream by wrapping an existing output-stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this output-stream and releases any system resources
associated with this stream.
|
void |
flush()
Flushes the underlying output-stream.
|
void |
write(byte[] bytes)
Writes the specified bytes to this output-stream.
|
void |
write(byte[] bytes,
int offset,
int length)
Writes the specified number of bytes to this output-stream starting at the
specified offset.
|
void |
write(int b)
Writes the specified byte to this output-stream.
|
void |
writeLength(int length)
Writes a length to the output-stream (if TLV state allows it).
|
void |
writeTag(int tag)
Writes a tag to the output-stream (if TLV state allows it).
|
void |
writeValue(byte[] value)
Writes a value at once.
|
void |
writeValueEnd()
Marks the end of the value written thus far.
|
public TLVOutputStream(java.io.OutputStream outputStream)
outputStream - the existing output-streampublic void writeTag(int tag)
throws java.io.IOException
tag - the tag to writejava.io.IOException - on error writing to the underlying output-streampublic void writeLength(int length)
throws java.io.IOException
length - the length to writejava.io.IOException - on error writing to the underlying output-streampublic void writeValue(byte[] value)
throws java.io.IOException
value.
If length was previously written, this method will check whether the length is consistent with value's length.value - the value to writejava.io.IOException - on error writing to the underlying output-streampublic void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamb - the byte to writejava.io.IOException - on error writing to the underlying output-streampublic void write(byte[] bytes)
throws java.io.IOException
write in class java.io.OutputStreambytes - the bytes to writejava.io.IOException - on error writing to the underlying output-streampublic void write(byte[] bytes,
int offset,
int length)
throws java.io.IOException
write in class java.io.OutputStreambytes - the bytes to writeoffset - the offsetlength - the number of bytes to writejava.io.IOException - on error writing to the underlying output-streampublic void writeValueEnd()
throws java.io.IOException
java.io.IOException - on error writing to the underlying output-streampublic void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOException - on error writing to the underlying output-streampublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.OutputStreamjava.io.IOException - on error writing to the underlying output-streamCopyright © 2023. All rights reserved.