## loci.formats
Class DataTools

    java.lang.Object
      loci.formats.DataTools

public abstract class DataTools
extends Object

A utility class with convenience methods for reading, writing and decoding words.

Constructor Summary
`DataTools()`

Method Summary
`static int` `bytesToInt(byte[] bytes, boolean little)` Translates up to the first 4 bytes of a byte array to an int.
`static int` `bytesToInt(byte[] bytes, int off, boolean little)` Translates up to the first 4 bytes of a byte array beyond the given offset to an int.
`static int` `bytesToInt(byte[] bytes, int off, int len, boolean little)` Translates up to the first len bytes of a byte array beyond the given offset to an int.
`static int` `bytesToInt(short[] bytes, boolean little)` Translates up to the first 4 bytes of a byte array to an int.
`static int` `bytesToInt(short[] bytes, int off, boolean little)` Translates up to the first 4 bytes of a byte array beyond the given offset to an int.
`static int` `bytesToInt(short[] bytes, int off, int len, boolean little)` Translates up to the first len bytes of a byte array beyond the given offset to an int.
`static long` `bytesToLong(byte[] bytes, boolean little)` Translates up to the first 8 bytes of a byte array to a long.
`static long` `bytesToLong(byte[] bytes, int off, boolean little)` Translates up to the first 8 bytes of a byte array beyond the given offset to a long.
`static long` `bytesToLong(byte[] bytes, int off, int len, boolean little)` Translates up to the first len bytes of a byte array beyond the given offset to a long.
`static long` `bytesToLong(short[] bytes, boolean little)` Translates up to the first 8 bytes of a byte array to a long.
`static long` `bytesToLong(short[] bytes, int off, boolean little)` Translates up to the first 8 bytes of a byte array beyond the given offset to a long.
`static long` `bytesToLong(short[] bytes, int off, int len, boolean little)` Translates up to the first len bytes of a byte array beyond the given offset to a long.
`static short` `bytesToShort(byte[] bytes, boolean little)` Translates up to the first 2 bytes of a byte array to a short.
`static short` `bytesToShort(byte[] bytes, int off, boolean little)` Translates up to the first 2 bytes of a byte array beyond the given offset to a short.
`static short` `bytesToShort(byte[] bytes, int off, int len, boolean little)` Translates up to the first len bytes of a byte array beyond the given offset to a short.
`static short` `bytesToShort(short[] bytes, boolean little)` Translates up to the first 2 bytes of a byte array to a short.
`static short` `bytesToShort(short[] bytes, int off, boolean little)` Translates up to the first 2 bytes of a byte array byond the given offset to a short.
`static short` `bytesToShort(short[] bytes, int off, int len, boolean little)` Translates up to the first len bytes of a byte array byond the given offset to a short.
`static String` `bytesToString(short[] bytes)` Translates bytes from the given array into a string.
`static String` `bytesToString(short[] bytes, int off)` Translates bytes from the given array into a string.
`static String` `bytesToString(short[] bytes, int off, int len)` Translates bytes from the given array into a string.
`static short` `read2SignedBytes(RandomAccessFile in, boolean little)` Reads 2 signed bytes [-32768, 32767].
`static int` `read2UnsignedBytes(RandomAccessFile in, boolean little)` Reads 2 unsigned bytes [0, 65535].
`static int` `read4SignedBytes(RandomAccessFile in, boolean little)` Reads 4 signed bytes [-2147483648, 2147483647].
`static long` `read4UnsignedBytes(RandomAccessFile in, boolean little)` Reads 4 unsigned bytes [0, 4294967296].
`static long` `read8SignedBytes(RandomAccessFile in, boolean little)` Reads 8 signed bytes [-9223372036854775808, 9223372036854775807].
`static double` `readDouble(RandomAccessFile in, boolean little)` Reads 8 bytes in double precision IEEE format.
`static float` `readFloat(RandomAccessFile in, boolean little)` Reads 4 bytes in single precision IEEE format.
`static void` `readFully(RandomAccessFile in, byte[] bytes)` Reads bytes from the given random access file or array.
`static byte` `readSignedByte(RandomAccessFile in)` Reads 1 signed byte [-128, 127].
`static short` `readUnsignedByte(RandomAccessFile in)` Reads 1 unsigned byte [0, 255].
`static void` `writeInt(RandomAccessFile out, int v)` Writes an integer to the given random access file in little-endian format.
`static void` `writeReverseInt(RandomAccessFile out, int v)` Writes an integer to the given random access file in big-endian format.
`static void` `writeReverseShort(RandomAccessFile out, int v)` Writes a short to the given random access file in big-endian format.
`static void` `writeShort(RandomAccessFile out, int v)` Writes a short to the given random access file in little-endian format.
`static void` `writeString(RandomAccessFile out, String s)` Writes a string to the given random access file.

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

Constructor Detail

### DataTools

    public DataTools()

Method Detail

### readFully

    public static void readFully(RandomAccessFile in,
                                 byte[] bytes)
                          throws IOException

  Reads bytes from the given random access file or array.

  Throws:
    `IOException`

### readSignedByte

    public static byte readSignedByte(RandomAccessFile in)
                               throws IOException

  Reads 1 signed byte [-128, 127].

  Throws:
    `IOException`

### readUnsignedByte

    public static short readUnsignedByte(RandomAccessFile in)
                                  throws IOException

  Reads 1 unsigned byte [0, 255].

  Throws:
    `IOException`

### read2SignedBytes

    public static short read2SignedBytes(RandomAccessFile in,
                                         boolean little)
                                  throws IOException

  Reads 2 signed bytes [-32768, 32767].

  Throws:
    `IOException`

### read2UnsignedBytes

    public static int read2UnsignedBytes(RandomAccessFile in,
                                         boolean little)
                                  throws IOException

  Reads 2 unsigned bytes [0, 65535].

  Throws:
    `IOException`

### read4SignedBytes

    public static int read4SignedBytes(RandomAccessFile in,
                                       boolean little)
                                throws IOException

  Reads 4 signed bytes [-2147483648, 2147483647].

  Throws:
    `IOException`

### read4UnsignedBytes

    public static long read4UnsignedBytes(RandomAccessFile in,
                                          boolean little)
                                   throws IOException

  Reads 4 unsigned bytes [0, 4294967296].

  Throws:
    `IOException`

### read8SignedBytes

    public static long read8SignedBytes(RandomAccessFile in,
                                        boolean little)
                                 throws IOException

  Reads 8 signed bytes [-9223372036854775808, 9223372036854775807].

  Throws:
    `IOException`

### readFloat

    public static float readFloat(RandomAccessFile in,
                                  boolean little)
                           throws IOException

  Reads 4 bytes in single precision IEEE format.

  Throws:
    `IOException`

### readDouble

    public static double readDouble(RandomAccessFile in,
                                    boolean little)
                             throws IOException

  Reads 8 bytes in double precision IEEE format.

  Throws:
    `IOException`

### writeString

    public static void writeString(RandomAccessFile out,
                                   String s)
                            throws IOException

  Writes a string to the given random access file.

  Throws:
    `IOException`

### writeInt

    public static void writeInt(RandomAccessFile out,
                                int v)
                         throws IOException

  Writes an integer to the given random access file in little-endian format.

  Throws:
    `IOException`

### writeShort

    public static void writeShort(RandomAccessFile out,
                                  int v)
                           throws IOException

  Writes a short to the given random access file in little-endian format.

  Throws:
    `IOException`

### writeReverseInt

    public static void writeReverseInt(RandomAccessFile out,
                                       int v)
                                throws IOException

  Writes an integer to the given random access file in big-endian format.

  Throws:
    `IOException`

### writeReverseShort

    public static void writeReverseShort(RandomAccessFile out,
                                         int v)
                                  throws IOException

  Writes a short to the given random access file in big-endian format.

  Throws:
    `IOException`

### bytesToShort

    public static short bytesToShort(byte[] bytes,
                                     int off,
                                     int len,
                                     boolean little)

  Translates up to the first len bytes of a byte array beyond the given offset to a short. If there are fewer than 2 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToShort

    public static short bytesToShort(byte[] bytes,
                                     int off,
                                     boolean little)

  Translates up to the first 2 bytes of a byte array beyond the given offset to a short. If there are fewer than 2 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToShort

    public static short bytesToShort(byte[] bytes,
                                     boolean little)

  Translates up to the first 2 bytes of a byte array to a short. If there are fewer than 2 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToShort

    public static short bytesToShort(short[] bytes,
                                     int off,
                                     int len,
                                     boolean little)

  Translates up to the first len bytes of a byte array byond the given offset to a short. If there are fewer than 2 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToShort

    public static short bytesToShort(short[] bytes,
                                     int off,
                                     boolean little)

  Translates up to the first 2 bytes of a byte array byond the given offset to a short. If there are fewer than 2 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToShort

    public static short bytesToShort(short[] bytes,
                                     boolean little)

  Translates up to the first 2 bytes of a byte array to a short. If there are fewer than 2 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToInt

    public static int bytesToInt(byte[] bytes,
                                 int off,
                                 int len,
                                 boolean little)

  Translates up to the first len bytes of a byte array beyond the given offset to an int. If there are fewer than 4 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToInt

    public static int bytesToInt(byte[] bytes,
                                 int off,
                                 boolean little)

  Translates up to the first 4 bytes of a byte array beyond the given offset to an int. If there are fewer than 4 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToInt

    public static int bytesToInt(byte[] bytes,
                                 boolean little)

  Translates up to the first 4 bytes of a byte array to an int. If there are fewer than 4 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToInt

    public static int bytesToInt(short[] bytes,
                                 int off,
                                 int len,
                                 boolean little)

  Translates up to the first len bytes of a byte array beyond the given offset to an int. If there are fewer than 4 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToInt

    public static int bytesToInt(short[] bytes,
                                 int off,
                                 boolean little)

  Translates up to the first 4 bytes of a byte array beyond the given offset to an int. If there are fewer than 4 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToInt

    public static int bytesToInt(short[] bytes,
                                 boolean little)

  Translates up to the first 4 bytes of a byte array to an int. If there are fewer than 4 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToLong

    public static long bytesToLong(byte[] bytes,
                                   int off,
                                   int len,
                                   boolean little)

  Translates up to the first len bytes of a byte array beyond the given offset to a long. If there are fewer than 8 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToLong

    public static long bytesToLong(byte[] bytes,
                                   int off,
                                   boolean little)

  Translates up to the first 8 bytes of a byte array beyond the given offset to a long. If there are fewer than 8 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToLong

    public static long bytesToLong(byte[] bytes,
                                   boolean little)

  Translates up to the first 8 bytes of a byte array to a long. If there are fewer than 8 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToLong

    public static long bytesToLong(short[] bytes,
                                   int off,
                                   int len,
                                   boolean little)

  Translates up to the first len bytes of a byte array beyond the given offset to a long. If there are fewer than 8 bytes to be translated, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToLong

    public static long bytesToLong(short[] bytes,
                                   int off,
                                   boolean little)

  Translates up to the first 8 bytes of a byte array beyond the given offset to a long. If there are fewer than 8 bytes to be translated, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToLong

    public static long bytesToLong(short[] bytes,
                                   boolean little)

  Translates up to the first 8 bytes of a byte array to a long. If there are fewer than 8 bytes in the array, the MSBs are all assumed to be zero (regardless of endianness).

### bytesToString

    public static String bytesToString(short[] bytes,
                                       int off,
                                       int len)

  Translates bytes from the given array into a string.

### bytesToString

    public static String bytesToString(short[] bytes,
                                       int off)

  Translates bytes from the given array into a string.

### bytesToString

    public static String bytesToString(short[] bytes)

  Translates bytes from the given array into a string.