ucar.unidata.io
Class BeLeDataInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.io.DataInputStream
              extended by ucar.unidata.io.BeLeDataInputStream
All Implemented Interfaces:
java.io.Closeable, java.io.DataInput

public class BeLeDataInputStream
extends java.io.DataInputStream

Big-endian little-endian data input stream, from which numbers in both big- and little-endian representations can be read. This is needed for ESRI shapefiles, for example, since they contain both big- and little-endian representations.

Version:
$Id: BeLeDataInputStream.java 64 2006-07-12 22:30:50Z edavis $
Author:
Russ Rew

Constructor Summary
BeLeDataInputStream(java.io.InputStream inputStream)
          Construct a bigEndian-littleEndian input stream from an input stream.
BeLeDataInputStream(java.lang.String filename)
          Construct a bigEndian-littleEndian input stream from a file.
BeLeDataInputStream(java.net.URL url)
          Construct a bigEndian-littleEndian input stream from a URL.
 
Method Summary
 double readLEDouble()
          read a double in little endian format
 void readLEDoubles(double[] d, int n)
          Reads n little-endian doubles from a random access file.
 float readLEFloat()
          read an int in little endian format
 int readLEInt()
          read an int in little endian format
 long readLELong()
          read a long in little endian format
 void readLELongs(long[] lbuf, int n)
          Reads n little-endian longs from a random access file.
 
Methods inherited from class java.io.DataInputStream
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeLeDataInputStream

public BeLeDataInputStream(java.io.InputStream inputStream)
                    throws java.io.IOException
Construct a bigEndian-littleEndian input stream from an input stream.

Parameters:
inputStream - from which to read
Throws:
java.io.IOException - on read error

BeLeDataInputStream

public BeLeDataInputStream(java.lang.String filename)
                    throws java.io.IOException
Construct a bigEndian-littleEndian input stream from a file.

Parameters:
filename - of file
Throws:
java.io.IOException - on read error

BeLeDataInputStream

public BeLeDataInputStream(java.net.URL url)
                    throws java.io.IOException
Construct a bigEndian-littleEndian input stream from a URL.

Parameters:
url - of remote data
Throws:
java.io.IOException - if there was a problem reading the file.
Method Detail

readLEInt

public int readLEInt()
              throws java.io.IOException
read an int in little endian format

Returns:
int created from next 4 bytes in stream, in littleEndian order
Throws:
java.io.IOException - on read error

readLEFloat

public float readLEFloat()
                  throws java.io.IOException
read an int in little endian format

Returns:
int created from next 4 bytes in stream, in littleEndian order
Throws:
java.io.IOException - on read error

readLEDouble

public double readLEDouble()
                    throws java.io.IOException
read a double in little endian format

Returns:
double from next 8 bytes in stream, littleEndian order
Throws:
java.io.IOException - on read error

readLEDoubles

public final void readLEDoubles(double[] d,
                                int n)
                         throws java.io.IOException
Reads n little-endian doubles from a random access file.

This method is provided for speed when accessing a number of consecutive values of the same type.

Parameters:
d - the buffer into which the doubles are read
n - number of little-endian doubles to read
Throws:
java.io.IOException - on read error

readLELong

public long readLELong()
                throws java.io.IOException
read a long in little endian format

Returns:
long from next 8 bytes in stream, littleEndian order
Throws:
java.io.IOException - on read error

readLELongs

public final void readLELongs(long[] lbuf,
                              int n)
                       throws java.io.IOException
Reads n little-endian longs from a random access file.

This method is provided for speed when accessing a number of consecutive values of the same type.

Parameters:
lbuf - the buffer into which the longs are read
n - the number of little-endian longs to read
Throws:
java.io.IOException - on read error