public final class HexOutputStream extends OutputStream
When a hex output stream is closed, its wrapped Appendable
will be closed as well if it implements Closeable
or
AutoCloseable
.
Constructor and Description |
---|
HexOutputStream(Appendable destination)
Creates a new hex output stream.
|
HexOutputStream(Appendable destination,
boolean upperCase)
Creates a new hex output stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
static String |
encode(byte[] b)
Converts a byte array to its lower case hex representation.
|
static String |
encode(byte[] b,
boolean upperCase)
Converts a byte array to its hex representation.
|
static String |
encode(byte[] b,
int start,
int end)
Converts a portion of byte array to its lower case hex representation.
|
static String |
encode(byte[] b,
int start,
int end,
boolean upperCase)
Converts a portion of a byte array to its hex representation.
|
void |
flush() |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
write
public HexOutputStream(Appendable destination)
destination
- The appendable to write to.NullPointerException
- If the given appendable is null
.public HexOutputStream(Appendable destination, boolean upperCase)
destination
- The appendable to write to.upperCase
- true
to write hex in upper case, or false
to write hex in lower case.NullPointerException
- If the given appendable is null
.public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public static String encode(byte[] b)
b
- The byte array to convert.NullPointerException
- If the given byte array is null
.public static String encode(byte[] b, int start, int end)
b
- The byte array to convert a portion of.start
- The start index of the portion to convert, inclusive.end
- The end index of the portion to convert, exclusive.NullPointerException
- If the given byte array is null
.IndexOutOfBoundsException
- If the given start index is negative, the given end index is larger than the given array's length,
or the given start index is larger than the given end index.public static String encode(byte[] b, boolean upperCase)
b
- The byte array to convert.upperCase
- true
to return hex in upper case, or false
to return hex in lower case.NullPointerException
- If the given byte array is null
.public static String encode(byte[] b, int start, int end, boolean upperCase)
b
- The byte array to convert a portion of.start
- The start index of the portion to convert, inclusive.end
- The end index of the portion to convert, exclusive.upperCase
- true
to return hex in upper case, or false
to return hex in lower case.NullPointerException
- If the given byte array is null
.IndexOutOfBoundsException
- If the given start index is negative, the given end index is larger than the given array's length,
or the given start index is larger than the given end index.Copyright © 2020–2024. All rights reserved.