public class HexDumpEncoder extends Object
xxxx: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ................Where xxxx is the offset into the buffer in 16 byte chunks, followed by ascii coded hexadecimal bytes followed by the ASCII representation of the bytes or '.' if they are not valid bytes.
| 限定符和类型 | 字段和说明 |
|---|---|
private int |
currentByte |
private int |
offset |
protected PrintStream |
pStream
Stream that understands "printing"
|
private byte[] |
thisLine |
private int |
thisLineLength |
| 构造器和说明 |
|---|
HexDumpEncoder() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected int |
bytesPerAtom() |
protected int |
bytesPerLine() |
String |
encode(byte[] aBuffer)
A 'streamless' version of encode that simply takes a buffer of
bytes and returns a string containing the encoded buffer.
|
String |
encode(ByteBuffer aBuffer)
A 'streamless' version of encode that simply takes a ByteBuffer
and returns a string containing the encoded buffer.
|
void |
encode(InputStream inStream,
OutputStream outStream)
Encode bytes from the input stream, and write them as text characters
to the output stream.
|
protected void |
encodeAtom(OutputStream o,
byte[] buf,
int off,
int len) |
String |
encodeBuffer(byte[] aBuffer)
A 'streamless' version of encode that simply takes a buffer of
bytes and returns a string containing the encoded buffer.
|
void |
encodeBuffer(byte[] aBuffer,
OutputStream aStream)
Encode the buffer in aBuffer and write the encoded
result to the OutputStream aStream.
|
void |
encodeBuffer(ByteBuffer aBuffer,
OutputStream aStream)
Encode the aBuffer ByteBuffer and write the encoded
result to the OutputStream aStream.
|
void |
encodeBuffer(InputStream inStream,
OutputStream outStream)
Encode bytes from the input stream, and write them as text characters
to the output stream.
|
protected void |
encodeBufferPrefix(OutputStream o) |
protected void |
encodeLinePrefix(OutputStream o,
int len) |
protected void |
encodeLineSuffix(OutputStream o) |
private byte[] |
getBytes(ByteBuffer bb)
Return a byte array from the remaining bytes in this ByteBuffer.
|
(专用程序包) static void |
hexDigit(PrintStream p,
byte x) |
protected int |
readFully(InputStream in,
byte[] buffer)
This method works around the bizarre semantics of BufferedInputStream's
read method.
|
private int offset
private int thisLineLength
private int currentByte
private byte[] thisLine
protected PrintStream pStream
static void hexDigit(PrintStream p, byte x)
protected int bytesPerAtom()
protected int bytesPerLine()
protected void encodeBufferPrefix(OutputStream o) throws IOException
IOExceptionprotected void encodeLinePrefix(OutputStream o, int len) throws IOException
IOExceptionprotected void encodeAtom(OutputStream o, byte[] buf, int off, int len) throws IOException
IOExceptionprotected void encodeLineSuffix(OutputStream o) throws IOException
IOExceptionprotected int readFully(InputStream in, byte[] buffer) throws IOException
IOExceptionpublic void encode(InputStream inStream, OutputStream outStream) throws IOException
IOExceptionpublic String encode(byte[] aBuffer)
private byte[] getBytes(ByteBuffer bb)
The ByteBuffer's position will be advanced to ByteBuffer's limit.
To avoid an extra copy, the implementation will attempt to return the byte array backing the ByteBuffer. If this is not possible, a new byte array will be created.
public String encode(ByteBuffer aBuffer)
The ByteBuffer's position will be advanced to ByteBuffer's limit.
public void encodeBuffer(InputStream inStream, OutputStream outStream) throws IOException
IOExceptionpublic void encodeBuffer(byte[] aBuffer,
OutputStream aStream)
throws IOException
IOExceptionpublic String encodeBuffer(byte[] aBuffer)
public void encodeBuffer(ByteBuffer aBuffer, OutputStream aStream) throws IOException
The ByteBuffer's position will be advanced to ByteBuffer's limit.
IOExceptionCopyright © 2023. All rights reserved.