Class IOHelper


  • public final class IOHelper
    extends java.lang.Object
    Generic IO routines. Supports printing and reading arrays of bytes. Also, using the setReader and setWriter methods, the source of the bytes can come from any stream as well as the destination for written bytes. All routines are static and final and handle all exceptional cases by returning a default value.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] readBytes​(int count, int pad, boolean hex)  
      static byte[] readBytesAsc​(int count, int pad)  
      static byte[] readBytesHex​(int count, int pad)  
      static int readInt()  
      static int readInt​(int def)  
      static java.lang.String readLine()  
      static void setReader​(java.io.Reader r)  
      static void setWriter​(java.io.Writer w)  
      static void write​(boolean b)  
      static void write​(int i)  
      static void write​(java.lang.Object o)  
      static void write​(java.lang.String s)  
      static void writeBytes​(byte[] b)
      Writes a byte[] to the specified output stream.
      static void writeBytes​(byte[] b, int offset, int cnt)  
      static void writeBytes​(java.lang.String delim, byte[] b, int offset, int cnt)
      Writes a byte[] to the specified output stream.
      static void writeBytesHex​(byte[] b)  
      static void writeBytesHex​(byte[] b, int offset, int cnt)  
      static void writeBytesHex​(java.lang.String delim, byte[] b, int offset, int cnt)  
      static void writeHex​(byte b)  
      static void writeHex​(long l)  
      static void writeLine()  
      static void writeLine​(boolean b)  
      static void writeLine​(int i)  
      static void writeLine​(java.lang.Object o)  
      static void writeLine​(java.lang.String s)  
      static void writeLineHex​(byte b)  
      static void writeLineHex​(long l)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setReader

        public static final void setReader​(java.io.Reader r)
      • readLine

        public static final java.lang.String readLine()
      • readBytes

        public static final byte[] readBytes​(int count,
                                             int pad,
                                             boolean hex)
      • readBytesHex

        public static final byte[] readBytesHex​(int count,
                                                int pad)
      • readBytesAsc

        public static final byte[] readBytesAsc​(int count,
                                                int pad)
      • readInt

        public static final int readInt()
      • readInt

        public static final int readInt​(int def)
      • setWriter

        public static final void setWriter​(java.io.Writer w)
      • writeBytesHex

        public static final void writeBytesHex​(java.lang.String delim,
                                               byte[] b,
                                               int offset,
                                               int cnt)
      • writeBytesHex

        public static final void writeBytesHex​(byte[] b,
                                               int offset,
                                               int cnt)
      • writeBytesHex

        public static final void writeBytesHex​(byte[] b)
      • writeBytes

        public static final void writeBytes​(java.lang.String delim,
                                            byte[] b,
                                            int offset,
                                            int cnt)
        Writes a byte[] to the specified output stream. This method writes a combined hex and ascii representation where each line has (at most) 16 bytes of data in hex followed by three spaces and the ascii representation of those bytes. To write out just the Hex representation, use writeBytesHex(byte[],int,int).
        Parameters:
        b - the byte array to print out.
        offset - the starting location to begin printing
        cnt - the number of bytes to print.
      • writeBytes

        public static final void writeBytes​(byte[] b)
        Writes a byte[] to the specified output stream. This method writes a combined hex and ascii representation where each line has (at most) 16 bytes of data in hex followed by three spaces and the ascii representation of those bytes. To write out just the Hex representation, use writeBytesHex(byte[],int,int).
        Parameters:
        b - the byte array to print out.
      • writeBytes

        public static final void writeBytes​(byte[] b,
                                            int offset,
                                            int cnt)
      • write

        public static final void write​(java.lang.String s)
      • write

        public static final void write​(java.lang.Object o)
      • write

        public static final void write​(boolean b)
      • write

        public static final void write​(int i)
      • writeLine

        public static final void writeLine()
      • writeLine

        public static final void writeLine​(java.lang.String s)
      • writeLine

        public static final void writeLine​(java.lang.Object o)
      • writeLine

        public static final void writeLine​(boolean b)
      • writeLine

        public static final void writeLine​(int i)
      • writeHex

        public static final void writeHex​(byte b)
      • writeHex

        public static final void writeHex​(long l)
      • writeLineHex

        public static final void writeLineHex​(byte b)
      • writeLineHex

        public static final void writeLineHex​(long l)