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

## com.google.common.io
Class LittleEndianDataInputStream

    java.lang.Object
      java.io.InputStream
          java.io.FilterInputStream
              com.google.common.io.LittleEndianDataInputStream

All Implemented Interfaces:
  Closeable, DataInput

    @Beta
    public final class LittleEndianDataInputStream

extends FilterInputStream
implements DataInput

An implementation of `DataInput` that uses little-endian byte ordering for reading `short`, `int`, `float`, `double`, and `long` values.

Note: This class intentionally violates the specification of its supertype `DataInput`, which explicitly requires big-endian byte order.

Since:
  8.0
Author:
  Chris Nokleberg, Keith Bottner

Field Summary

Fields inherited from class java.io.FilterInputStream
`in`

Constructor Summary
`LittleEndianDataInputStream(InputStream in)` Creates a `LittleEndianDataInputStream` that wraps the given stream.

Method Summary
`boolean` | `readBoolean()`
`byte` | `readByte()`
`char` | `readChar()` Reads a char as specified by `DataInputStream.readChar()`, except using little-endian byte order.
`double` | `readDouble()` Reads a `double` as specified by `DataInputStream.readDouble()`, except using little-endian byte order.
`float` | `readFloat()` Reads a `float` as specified by `DataInputStream.readFloat()`, except using little-endian byte order.
`void` | `readFully(byte[] b)`
`void` | `readFully(byte[] b, int off, int len)`
`int` | `readInt()` Reads an integer as specified by `DataInputStream.readInt()`, except using little-endian byte order.
`String` | `readLine()` This method will throw a `UnsupportedOperationException`.
`long` | `readLong()` Reads a `long` as specified by `DataInputStream.readLong()`, except using little-endian byte order.
`short` | `readShort()` Reads a `short` as specified by `DataInputStream.readShort()`, except using little-endian byte order.
`int` | `readUnsignedByte()`
`int` | `readUnsignedShort()` Reads an unsigned `short` as specified by `DataInputStream.readUnsignedShort()`, except using little-endian byte order.
`String` | `readUTF()`
`int` | `skipBytes(int n)`

Methods inherited from class java.io.FilterInputStream
`available, close, mark, markSupported, read, read, read, reset, skip`

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

Constructor Detail

### LittleEndianDataInputStream

    public LittleEndianDataInputStream(InputStream in)

  Creates a `LittleEndianDataInputStream` that wraps the given stream.

  Parameters:
    `in` - the stream to delegate to

Method Detail

### readLine

    public String readLine()

  This method will throw a `UnsupportedOperationException`.

  Specified by:
    `readLine` in interface `DataInput`

### readFully

    public void readFully(byte[] b)
                   throws IOException

  Specified by:
    `readFully` in interface `DataInput`
  Throws:
    `IOException`

### readFully

    public void readFully(byte[] b,
                          int off,
                          int len)
                   throws IOException

  Specified by:
    `readFully` in interface `DataInput`
  Throws:
    `IOException`

### skipBytes

    public int skipBytes(int n)
                  throws IOException

  Specified by:
    `skipBytes` in interface `DataInput`
  Throws:
    `IOException`

### readUnsignedByte

    public int readUnsignedByte()
                         throws IOException

  Specified by:
    `readUnsignedByte` in interface `DataInput`
  Throws:
    `IOException`

### readUnsignedShort

    public int readUnsignedShort()
                          throws IOException

  Reads an unsigned `short` as specified by `DataInputStream.readUnsignedShort()`, except using little-endian byte order.

  Specified by:
    `readUnsignedShort` in interface `DataInput`
  Returns:
    the next two bytes of the input stream, interpreted as an `int` in little-endian byte order
  Throws:
    `IOException` - if an I/O error occurs

### readInt

    public int readInt()
                throws IOException

  Reads an integer as specified by `DataInputStream.readInt()`, except using little-endian byte order.

  Specified by:
    `readInt` in interface `DataInput`
  Returns:
    the next four bytes of the input stream, interpreted as an `int` in little-endian byte order
  Throws:
    `IOException` - if an I/O error occurs

### readLong

    public long readLong()
                  throws IOException

  Reads a `long` as specified by `DataInputStream.readLong()`, except using little-endian byte order.

  Specified by:
    `readLong` in interface `DataInput`
  Returns:
    the next eight bytes of the input stream, interpreted as a `long` in little-endian byte order
  Throws:
    `IOException` - if an I/O error occurs

### readFloat

    public float readFloat()
                    throws IOException

  Reads a `float` as specified by `DataInputStream.readFloat()`, except using little-endian byte order.

  Specified by:
    `readFloat` in interface `DataInput`
  Returns:
    the next four bytes of the input stream, interpreted as an `float` in little-endian byte order
  Throws:
    `IOException` - if an I/O error occurs

### readDouble

    public double readDouble()
                      throws IOException

  Reads a `double` as specified by `DataInputStream.readDouble()`, except using little-endian byte order.

  Specified by:
    `readDouble` in interface `DataInput`
  Returns:
    the next eight bytes of the input stream, interpreted as an `int` in little-endian byte order
  Throws:
    `IOException` - if an I/O error occurs

### readUTF

    public String readUTF()
                   throws IOException

  Specified by:
    `readUTF` in interface `DataInput`
  Throws:
    `IOException`

### readShort

    public short readShort()
                    throws IOException

  Reads a `short` as specified by `DataInputStream.readShort()`, except using little-endian byte order.

  Specified by:
    `readShort` in interface `DataInput`
  Returns:
    the next two bytes of the input stream, interpreted as an `short` in little-endian byte order.
  Throws:
    `IOException` - if an I/O error occurs.

### readChar

    public char readChar()
                  throws IOException

  Reads a char as specified by `DataInputStream.readChar()`, except using little-endian byte order.

  Specified by:
    `readChar` in interface `DataInput`
  Returns:
    the next two bytes of the input stream, interpreted as an `char` in little-endian byte order
  Throws:
    `IOException` - if an I/O error occurs

### readByte

    public byte readByte()
                  throws IOException

  Specified by:
    `readByte` in interface `DataInput`
  Throws:
    `IOException`

### readBoolean

    public boolean readBoolean()
                        throws IOException

  Specified by:
    `readBoolean` in interface `DataInput`
  Throws:
    `IOException`

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

Copyright © 2010-2011. All Rights Reserved.