Class Input

java.lang.Object
com.xinapse.io.Input

public abstract class Input extends Object
Abstract class providing methods to read primitve data values from input sources. The byte order of the data source can be specified for multi-byte primitive values.
  • Method Details

    • Short

      public static short Short(InputStream strm, ByteOrder byteOrder) throws IOException, EOFException
      Reads a short value from a InputStream strm, ensuring that blocking occurs until the value has been read.
      Parameters:
      strm - the InputStream from which the short value will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      Returns:
      a short value read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • Short

      public static short Short(RandomAccessFile f, ByteOrder byteOrder) throws IOException, EOFException
      Reads a short value from a RandomAccessFile f, ensuring that blocking occurs until the value has been read.
      Parameters:
      f - the RandomAccessFile from which the short value will be read.
      byteOrder - the ByteOrder of the data in the RandomAccessFile.
      Returns:
      a short value read from the RandomAccessFile.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • UShort

      public static int UShort(InputStream strm, ByteOrder byteOrder) throws EOFException, IOException
      Reads an unsigned short value from a InputStream strm, ensuring that blocking occurs until the value has been read.
      Parameters:
      strm - the InputStream from which the unsigned short value will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      Returns:
      a unsigned short value read from the InputStream, as an int.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • UShort

      public static int UShort(RandomAccessFile f, ByteOrder byteOrder) throws IOException, EOFException
      Reads an unsigned short value from a RandomAccessFile f, ensuring that blocking occurs until the value has been read.
      Parameters:
      f - the RandomAccessFile from which the unsigned short value will be read.
      byteOrder - the ByteOrder of the data in the RandomAccessFile.
      Returns:
      an unsigned short value read from the RandomAccessFile, as an int.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • UShort

      public static int UShort(byte[] b, int offset)
      Gets an int value from an array of 2 bytes. The bytes are assumed to be in big-endian order.
      Parameters:
      b - the byte[] of length at least 2+offset from which the unsigned short value will be created.
      offset - the offset into the array at which reading of the byte values will begin.
      Returns:
      an int value created from 2 bytes representing an unsigned short value.
    • Integer

      public static int Integer(InputStream strm, ByteOrder byteOrder) throws EOFException, IOException
      Reads an integer value from a InputStream strm, ensuring that blocking occurs until the value has been read.
      Parameters:
      strm - the InputStream from which the int value will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      Returns:
      an int value read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • Integer

      public static int Integer(RandomAccessFile f, ByteOrder byteOrder) throws EOFException, IOException
      Reads an integer value from a RandomAccessFile f, ensuring that blocking occurs until the value has been read.
      Parameters:
      f - the RandomAccessFile from which the integer value will be read.
      byteOrder - the ByteOrder of the data in the RandomAccessFile.
      Returns:
      an int value read from the RandomAccessFile.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • Integer

      public static int Integer(byte[] b, int offset)
      Gets an int value from an array of 4 bytes. The bytes are assumed to be in big-endian order.
      Parameters:
      b - the byte[] of length at least 4+offset from which the integer value will be created.
      offset - the offset into the array at which reading of the byte values will begin.
      Returns:
      an int value created from 4 bytes.
    • UInteger

      public static long UInteger(InputStream strm, ByteOrder byteOrder) throws EOFException, IOException
      Reads an unsigned integer value from a RandomAccessFile f, ensuring that blocking occurs until the value has been read.
      Parameters:
      strm - the InputStream from which the unsigned int value will be read.
      byteOrder - the ByteOrder of the data in the RandomAccessFile.
      Returns:
      an unsigned int value read from the RandomAccessFile, as a long.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • UInteger

      public static long UInteger(RandomAccessFile f, ByteOrder byteOrder) throws EOFException, IOException
      Reads an unsigned integer value from a RandomAccessFile f, ensuring that blocking occurs until the value has been read.
      Parameters:
      f - the RandomAccessFile from which the unsigned int value will be read.
      byteOrder - the ByteOrder of the data in the RandomAccessFile.
      Returns:
      an unsigned int value read from the RandomAccessFile, as a long.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • Long

      public static long Long(InputStream strm, ByteOrder byteOrder) throws EOFException, IOException
      Reads a long value from a InputStream strm, ensuring that blocking occurs until the value has been read.
      Parameters:
      strm - the InputStream from which the long value will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      Returns:
      a long value read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • Long

      public static long Long(RandomAccessFile f, ByteOrder byteOrder) throws EOFException, IOException
      Reads a long value from a RandomAccessFile f, ensuring that blocking occurs until the value has been read.
      Parameters:
      f - the RandomAccessFile from which the long value will be read.
      byteOrder - the ByteOrder of the data in the RandomAccessFile.
      Returns:
      a long value read from the RandomAccessFile.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • Float

      public static float Float(InputStream strm, ByteOrder byteOrder) throws EOFException, IOException
      Reads a float value from a InputStream strm, ensuring that blocking occurs until the value has been read.
      Parameters:
      strm - the InputStream from which the float value will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      Returns:
      a float value read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • Float

      public static float Float(RandomAccessFile f, ByteOrder byteOrder) throws EOFException, IOException
      Reads a float value from a RandomAccessFile f, ensuring that blocking occurs until the value has been read.
      Parameters:
      f - the RandomAccessFile from which the float value will be read.
      byteOrder - the ByteOrder of the data in the RandomAccessFile.
      Returns:
      a float value read from the RandomAccessFile.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • Double

      public static double Double(InputStream strm, ByteOrder byteOrder) throws EOFException, IOException
      Reads a double value from a InputStream strm, ensuring that blocking occurs until the value has been read.
      Parameters:
      strm - the InputStream from which the double value will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      Returns:
      a double value read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • Double

      public static double Double(RandomAccessFile f, ByteOrder byteOrder) throws EOFException, IOException
      Reads a double value from a RandomAccessFile f, ensuring that blocking occurs until the value has been read.
      Parameters:
      f - the RandomAccessFile from which the double value will be read.
      byteOrder - the ByteOrder of the data in the RandomAccessFile.
      Returns:
      a double value read from the RandomAccessFile.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • String

      public static String String(InputStream strm, int nBytes) throws EOFException, IOException
      Reads a String from a InputStream strm, by decoding the bytes read using the Output. DEFAULT_CHARSET charset and ensuring that blocking occurs until the String has been read.
      Parameters:
      strm - the InputStream from which the String will be read.
      nBytes - the length of the String, in bytes.
      Returns:
      a String value read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • String

      public static String String(InputStream strm, int nBytes, Charset charset) throws EOFException, IOException
      Reads a String from a InputStream strm, by decoding the bytes read using the specified charset and ensuring that blocking occurs until the String has been read.
      Parameters:
      strm - the InputStream from which the String will be read.
      nBytes - the length of the String, in bytes.
      charset - the Charset to use for decoding.
      Returns:
      a String value read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • String

      public static String String(RandomAccessFile f, int nBytes) throws EOFException, IOException
      Reads a String from a RandomAccessFile f, ensuring that blocking occurs until the String has been read.
      Parameters:
      f - the RandomAccessFile from which the String will be read.
      nBytes - the length of the String, in bytes.
      Returns:
      a String value read from the RandomAccessFile.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • ByteArray

      public static byte[] ByteArray(InputStream strm, int nBytes) throws EOFException, IOException
      Reads an array of bytes from a InputStream strm ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the InputStream from which the bytes will be read.
      nBytes - the number of bytes to read.
      Returns:
      an array of bytes read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • ByteArray

      public static byte[] ByteArray(RandomAccessFile f, int nBytes) throws EOFException, IOException
      Reads an array of bytes from a RandomAccessFile f, ensuring that blocking occurs until all values have been read.
      Parameters:
      f - the RandomAccessFile from which the bytes will be read.
      nBytes - the number of bytes to read.
      Returns:
      an array of bytes read from the RandomAccessFile.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • BitSet

      public static long BitSet(InputStream strm, BitSet bitSet) throws IOException
      Reads a BitSet from a InputStream strm ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the InputStream from which the boolean (binary) values will be read.
      bitSet - the BitSet that will be filled by this method. The number of values to be read is specified by the length of bitSet.
      Returns:
      the number of bytes read (rounded up to the next byte if a whole number of bytes is not read).
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • BitSet

      public static long BitSet(DataInputStream strm, BitSet bitSet) throws IOException
      Reads a BitSet from a DataInputStream strm, ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the DataInputStream from which the boolean (binary) values will be read.
      bitSet - the BitSet that will be filled by this method. The number of values to be read is specified by the length of bitSet.
      Returns:
      the number of bytes read (rounded up to the next byte if a whole number of bytes is not read).
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • BitSet

      public static long BitSet(RandomAccessFile f, BitSet bitSet, int bitOffset) throws IOException
      Reads a BitSet from a RandomAccessFile f, ensuring that blocking occurs until all values have been read.
      Parameters:
      f - the RandomAccessFile from which the boolean (binary) values will be read.
      bitSet - the BitSet that will be filled by this method. The number of values to be read is specified by the length of bitSet.
      bitOffset - an offset (in bits) from the current location in the RandomAccessFile to the point where reading bits should start.
      Returns:
      the number of bytes read (rounded up to the next byte if a whole number of bytes is not read).
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • ShortArray

      public static short[] ShortArray(InputStream strm, ByteOrder byteOrder, int nShorts) throws EOFException, IOException
      Reads an array of short values from a InputStream strm ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the InputStream from which the short values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      nShorts - the number of short values to read.
      Returns:
      an array of short values read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • ShortArray

      public static short[] ShortArray(DataInputStream strm, ByteOrder byteOrder, short[] sArray) throws IOException, EOFException
      Reads an array of short values from a DataInputStream strm ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the DataInputStream from which the short values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      sArray - the array into which the short values read will be stored.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O occurs during the read.
    • ShortArray

      public static short[] ShortArray(RandomAccessFile f, ByteOrder byteOrder, short[] sArray) throws IOException, EOFException
      Reads an array of short values from a RandomAccessFile f ensuring that blocking occurs until all values have been read.
      Parameters:
      f - the RandomAccessFile from which the short values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      sArray - the array into which the short values read will be stored.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • ShortArray

      public static short[] ShortArray(RandomAccessFile f, ByteOrder byteOrder, short[] sArray, int off, int len) throws IOException, EOFException
      Reads an array of short values from a RandomAccessFile f ensuring that blocking occurs until all values have been read.
      Parameters:
      f - the RandomAccessFile from which the short values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      sArray - the array into which the short values read will be stored.
      off - the offset into the array (a number of short values) at which the storage of the values read will start.
      len - the number of short values to read from the RandomAccessFile.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • IntArray

      public static int[] IntArray(InputStream strm, ByteOrder byteOrder, int nInts) throws EOFException, IOException
      Reads an array of int values from a InputStream strm ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the InputStream from which the int values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      nInts - the number of int values to read.
      Returns:
      an array of int values read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • IntArray

      public static int[] IntArray(DataInputStream strm, ByteOrder byteOrder, int[] iArray) throws IOException
      Reads an array of int values from a DataInputStream strm ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the DataInputStream from which the int values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      iArray - the array into which the int values read will be stored.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • IntArray

      public static int[] IntArray(RandomAccessFile f, ByteOrder byteOrder, int[] iArray) throws IOException
      Reads an array of int values from a RandomAccessFile f ensuring that blocking occurs until all values have been read.
      Parameters:
      f - the RandomAccessFile from which the int values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      iArray - the array into which the int values read will be stored.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • IntArray

      public static int[] IntArray(RandomAccessFile f, ByteOrder byteOrder, int[] iArray, int off, int len) throws IOException
      Reads an array of int values from a RandomAccessFile f ensuring that blocking occurs until all values have been read.
      Parameters:
      f - the RandomAccessFile from which the int values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      iArray - the array into which the int values read will be stored.
      off - the offset into the array (a number of int values) at which the storage of the values read will start.
      len - the number of int values to read from the RandomAccessFile.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • LongArray

      public static long[] LongArray(InputStream strm, ByteOrder byteOrder, int nLongs) throws EOFException, IOException
      Reads an array of long values from a InputStream strm ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the InputStream from which the int values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      nLongs - the number of long values to read.
      Returns:
      an array of long values read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • LongArray

      public static long[] LongArray(DataInputStream strm, ByteOrder byteOrder, long[] lArray) throws IOException
      Reads an array of long values from a DataInputStream strm ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the DataInputStream from which the long values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      lArray - the array into which the long values read will be stored.
      Returns:
      an array of long values read from the DataInputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • LongArray

      public static long[] LongArray(RandomAccessFile f, ByteOrder byteOrder, long[] lArray) throws IOException
      Reads an array of long values from a RandomAccessFile f ensuring that blocking occurs until all values have been read.
      Parameters:
      f - the RandomAccessFile from which the long values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      lArray - the array into which the long values read will be stored.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • LongArray

      public static long[] LongArray(RandomAccessFile f, ByteOrder byteOrder, long[] lArray, int off, int len) throws IOException
      Reads an array of long values from a RandomAccessFile f, ensuring that blocking occurs until all values have been read.
      Parameters:
      f - the RandomAccessFile from which the long values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      lArray - the array into which the long values read will be stored.
      off - the offset into the array (a number of long values) at which the storage of the values read will start.
      len - the number of long values to read from the RandomAccessFile.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • FloatArray

      public static float[] FloatArray(InputStream strm, ByteOrder byteOrder, int nFloats) throws EOFException, IOException
      Reads an array of float values from a InputStream strm ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the InputStream from which the float values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      nFloats - the number of float values to read.
      Returns:
      an array of float values read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • FloatArray

      public static float[] FloatArray(DataInputStream strm, ByteOrder byteOrder, float[] fArray) throws IOException
      Reads an array of float values from a DataInputStream strm ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the DataInputStream from which the float values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      fArray - the array into which the float values read will be stored.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • FloatArray

      public static float[] FloatArray(RandomAccessFile f, ByteOrder byteOrder, float[] fArray) throws IOException
      Reads an array of float values from a RandomAccessFile f ensuring that blocking occurs until all values have been read.
      Parameters:
      f - the RandomAccessFile from which the float values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      fArray - the array into which the float values read will be stored.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • FloatArray

      public static float[] FloatArray(RandomAccessFile f, ByteOrder byteOrder, float[] fArray, int off, int len) throws IOException
      Reads an array of float values from a RandomAccessFile f ensuring that blocking occurs until all values have been read.
      Parameters:
      f - the RandomAccessFile from which the float values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      fArray - the array into which the float values read will be stored.
      off - the offset into the array (a number of float values) at which the storage of the values read will start.
      len - the number of float values to read from the RandomAccessFile.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • DoubleArray

      public static double[] DoubleArray(InputStream strm, ByteOrder byteOrder, int nDoubles) throws EOFException, IOException
      Reads an array of double values from a InputStream strm ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the InputStream from which the double values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      nDoubles - the number of double values to read.
      Returns:
      an array of double values read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • DoubleArray

      public static double[] DoubleArray(InputStream strm, ByteOrder byteOrder, double[] dArray) throws IOException
      Reads an array of double values from a DataInputStream strm ensuring that blocking occurs until all values have been read.
      Parameters:
      strm - the DataInputStream from which the double values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      dArray - the array into which the double values read will be stored.
      Returns:
      an array of double values read from the InputStream.
      Throws:
      EOFException - if the end of the stream is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • DoubleArray

      public static double[] DoubleArray(RandomAccessFile f, ByteOrder byteOrder, double[] dArray) throws IOException
      Reads an array of double values from a RandomAccessFile f ensuring that blocking occurs until all values have been read.
      Parameters:
      f - the RandomAccessFile from which the double values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      dArray - the array into which the double values read will be stored.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.
    • DoubleArray

      public static double[] DoubleArray(RandomAccessFile f, ByteOrder byteOrder, double[] dArray, int off, int len) throws IOException
      Reads an array of double values from a RandomAccessFile f ensuring that blocking occurs until all values have been read.
      Parameters:
      f - the RandomAccessFile from which the double values will be read.
      byteOrder - the ByteOrder of the data in the InputStream.
      dArray - the array into which the double values read will be stored.
      off - the offset into the array (a number of double values) at which the storage of the values read will start.
      len - the number of double values to read from the RandomAccessFile.
      Returns:
      the supplied array.
      Throws:
      EOFException - if the end of the file is reached before reading is completed.
      IOException - if an I/O error occurs during the read.