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:
Closeable, DataInput

public class BeLeDataInputStream
extends 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

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
BeLeDataInputStream(InputStream inputStream)
          Construct a bigEndian-littleEndian input stream from an input stream.
BeLeDataInputStream(String filename)
          Construct a bigEndian-littleEndian input stream from a file.
BeLeDataInputStream(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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeLeDataInputStream

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

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

BeLeDataInputStream

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

Parameters:
filename - of file
Throws:
IOException - on read error

BeLeDataInputStream

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

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

readLEInt

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

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

readLEFloat

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

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

readLEDouble

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

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

readLEDoubles

public final void readLEDoubles(double[] d,
                                int n)
                         throws 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:
IOException - on read error

readLELong

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

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

readLELongs

public final void readLELongs(long[] lbuf,
                              int n)
                       throws 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:
IOException - on read error


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.