Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.ifs.utils.io
Class ByteUtilities

    java.lang.Object
      oracle.ifs.utils.io.ByteUtilities

    public class ByteUtilities

extends java.lang.Object

A collection of methods that operate on byte arrays.

Note: unless explicitly specified otherwise, the methods in this class assume big-endian (network) byte order (most significant bit first).

Modified:
  lsaenz 07/27/2001 Fixed end of stream bug in readFromStream., lsaenz 06/29/2001 Fixed bug in setBytes() for 8 byte values., lsaenz 01/15/2001 Updated comments., lsaenz 01/10/2001 Added method: readFromStream; removed methods: set/clearBit., lsaenz 01/09/2001 Added methods: set/clearBit, mergeByteArrays, getPackedLength, main (for testing)., lsaenz 01/03/2001 Created.

Method Summary
`static long` | `bytesToLong(byte[] buffer, int offset, int length)` Returns the long value of a sequence of bytes in a byte array.
`static int` | `getPackedLength(byte[][] array)` Returns the length of the array that would result if the given source two-dimensional array was packed into a one-dimensional byte array.
`static void` | `main(java.lang.String[] args)` Tests this class.
`static void` | `mergeByteArrays(byte[][] src, byte[] dst, int offset)` Merges a two-dimensional byte array into a destination array.
`static byte[]` | `readFromStream(java.io.InputStream in, int length)` Creates a new byte array of a given length by reading from an InputStream.
`static void` | `setBytes(long value, byte[] buffer, int offset, int length)` Sets the value of a sequence of bytes in a byte array.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### main

    public static void main(java.lang.String[] args)

  Description copied from class: `ByteUtilities`
  Tests this class.

### bytesToLong

    public static long bytesToLong(byte[] buffer,
                                   int offset,
                                   int length)

  Description copied from class: `ByteUtilities`
  Returns the long value of a sequence of bytes in a byte array.

  Parameters:
    `buffer` - the byte array to convert to a long value.
    `offset` - the offset of the value in the byte array.
    `length` - the length (in bytes) of the value.
  Returns:
    a long representation of the specified subset of the given buffer.

### setBytes

    public static void setBytes(long value,
                                byte[] buffer,
                                int offset,
                                int length)

  Description copied from class: `ByteUtilities`
  Sets the value of a sequence of bytes in a byte array.

  Parameters:
    `value` - the value to set.
    `buffer` - the byte array to modify.
    `offset` - the offset in the byte array (the first byte to modify).
    `length` - the length (in bytes) of the value.

### mergeByteArrays

    public static void mergeByteArrays(byte[][] src,
                                       byte[] dst,
                                       int offset)

  Description copied from class: `ByteUtilities`
  Merges a two-dimensional byte array into a destination array. That is, the source array is flattened, or packed, and then copied into a destination byte array.
  Note: the source arrays will be copied in their entirity; that is, there is no source offset for each sub-array.

  Parameters:
    `src` - the source two-dimensional byte array.
    `dst` - the destination byte array.
    `offset` - the offset into the destination array where the new array will be copied.

### getPackedLength

    public static int getPackedLength(byte[][] array)

  Description copied from class: `ByteUtilities`
  Returns the length of the array that would result if the given source two-dimensional array was packed into a one-dimensional byte array.
  Note: this method's algorithm can be described as follows:
  `SUM(array[i].legnth), i = 0..array.length`

  Returns:
    the sum of the lengths of each sub-array in the given two-dimensional byte array.

### readFromStream

    public static byte[] readFromStream(java.io.InputStream in,
                                        int length)
                                 throws java.io.IOException

  Description copied from class: `ByteUtilities`
  Creates a new byte array of a given length by reading from an InputStream.
  Note: this method blocks until `length` bytes have been read, until the end of stream is reached, or an error occurs.

  Returns:
    a new byte array of length `length`, or null if the end of stream was reached before the `length` bytes were able to be read.
  Throws:
    `java.io.IOException` - if an error occurs while reading from the stream.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD