com.csss.opensource.jhexdump
Class JHexDumpReader

java.lang.Object
  extended bycom.csss.opensource.jhexdump.JHexDumpReader

public class JHexDumpReader
extends java.lang.Object

This class provides a reader that will convert an input stream into hexadecimal output. To use the class, instantiate an instance of the class, passing in the stream which you want to retreive as hexadecimal output, and then repeatedly invoke readLine() to retrieve the output. readLine() will return -1 when the end of the stream has been reached I've only tested the reader on InputStream based on either FileInputStream or... so I'm not sure of the results on input streams that may block.

Version:
1.1
Author:
Lee Walton - The jZone

Constructor Summary
JHexDumpReader(java.io.InputStream stream)
          Constructor.
JHexDumpReader(java.io.InputStream stream, int bytesPerRow, boolean noAscii, boolean noPosInd)
          Constructor.
 
Method Summary
 int getBytesPerRow()
          Returns the number of bytes per line.
 boolean isNoAscii()
          Returns the value of NoAscii.
 boolean isNoPosInd()
          Returns the value of NoPosInd.
 int readLine(java.lang.StringBuffer output)
          Processes a line of data from the InputStream
 void setBytesPerRow(int bytesPerRow)
          Sets the number of bytes per line.
 void setNoAscii(boolean noAscii)
          Sets the value of NoAscii.
 void setNoPosInd(boolean noPosInd)
          Sets the value of NoPosInd.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JHexDumpReader

public JHexDumpReader(java.io.InputStream stream)
Constructor.

Defaults are used for the BytesPerRow, NoAscii, and NoPosInd.

Parameters:
stream - The InputStream to process

JHexDumpReader

public JHexDumpReader(java.io.InputStream stream,
                      int bytesPerRow,
                      boolean noAscii,
                      boolean noPosInd)
Constructor.

Overides the defaults for BytesPerRow, NoAscii, and NoPosInd.

Parameters:
stream - The InputStream to process
bytesPerRow -
noAscii -
noPosInd -
Method Detail

getBytesPerRow

public int getBytesPerRow()
Returns the number of bytes per line.

Returns:
int

setBytesPerRow

public void setBytesPerRow(int bytesPerRow)
Sets the number of bytes per line.

Parameters:
bytesPerRow -

isNoAscii

public boolean isNoAscii()
Returns the value of NoAscii.

If set to true, the ASCII representation of the data is supressed. (defaults to false)

Returns:
boolean

setNoAscii

public void setNoAscii(boolean noAscii)
Sets the value of NoAscii.

If set to true, the ASCII representation of the data is supressed. (defaults to false)

Parameters:
noAscii -

isNoPosInd

public boolean isNoPosInd()
Returns the value of NoPosInd.

If set to true, the stream position indicator is supressed. (defaults to false)

Returns:
boolean

setNoPosInd

public void setNoPosInd(boolean noPosInd)
Sets the value of NoPosInd.

If set to true, the stream position indicator is supressed. (defaults to false)

Parameters:
noPosInd -

readLine

public int readLine(java.lang.StringBuffer output)
             throws java.io.IOException
Processes a line of data from the InputStream

The output will include a position indicator at the begining of the line if NoPosInd is false, and an ASCII representation of the line if NoAscii is false.

Parameters:
output - The StringBuffer to return the output in
Returns:
int The number of bytes read from the input stream
Throws:
java.io.IOException


Copyright © 2003-2004 C/S Software Solutions Ltd. All Rights Reserved.