Class DataIO


  • public class DataIO
    extends Object
    Methods for working with Data during I/O
    • Constructor Detail

      • DataIO

        public DataIO()
    • Method Detail

      • writeUTFv

        public static void writeUTFv​(String string,
                                     DataOutput out)
                              throws IOException
        Similar to writeUTF, but ok for strings > 32K bytes long and better for strings < 127 string utf-8 length must be ≤ Integer.MAX_VALUE - 1
        Parameters:
        string - the string to write
        out - the output sink
        Throws:
        IOException - passthru
      • writeShort

        public static void writeShort​(DataOutput out,
                                      int v)
                               throws IOException
        DataOutputStream writeShort with checking of argument
        Parameters:
        out - the output sink
        v - the value to write
        Throws:
        IOException - passthru
      • writeByte

        public static void writeByte​(DataOutput out,
                                     int v)
                              throws IOException
        DataOutputStream writeByte with checking of argument
        Parameters:
        out - output sink
        v - the value to write
        Throws:
        IOException - passthru
      • writeUnsignedByte

        public static void writeUnsignedByte​(DataOutput out,
                                             int v)
                                      throws IOException
        Write lower 8 bits
        Parameters:
        out - output sink
        v - the value to write
        Throws:
        IOException - passthru
      • writeVPNnumber

        public static void writeVPNnumber​(DataOutput out,
                                          int v)
                                   throws IOException
        write a positive or negative number, optimized for fewer bytes near 0 sign put in low order bit, rest of number converted to positive and shifted left 1 max negative written as - 0.
        Parameters:
        out - output sink
        v - the value to write
        Throws:
        IOException - passthru
      • lengthVPNnumber

        public static int lengthVPNnumber​(int v)
      • lengthVPNnumber

        public static int lengthVPNnumber​(long v)
      • writeVnumber

        public static void writeVnumber​(DataOutput out,
                                        int v)
                                 throws IOException
        Write a positive number with the fewest bytes possible up to 127 written as a byte high order bit on means get another byte Note: value treated as unsigned 32 bit int
        Parameters:
        out - output sink
        v - the value to write
        Throws:
        IOException - passthru
      • lengthVnumber

        public static int lengthVnumber​(int v)
      • writeVnumber

        public static void writeVnumber​(DataOutput out,
                                        long v)
                                 throws IOException
        Write a positive long with the fewest bytes possible; up to 127 written as a byte, high order bit on means get another byte.
        Parameters:
        out - output sink
        v - the value to write is never negative
        Throws:
        IOException - passthru
      • lengthVnumber

        public static int lengthVnumber​(long v)
      • writeIntArray

        public static void writeIntArray​(DataOutput out,
                                         int[] v)
                                  throws IOException
        write array preceded by its length
        Parameters:
        out - output sink
        v - the value to write
        Throws:
        IOException - passthru
      • writeIntArrayDelta

        public static void writeIntArrayDelta​(DataOutput out,
                                              int[] v)
                                       throws IOException
        Write delta encoded value, for increasing values
        Parameters:
        out - output sink
        v - the value to write
        Throws:
        IOException - passthru