edu.mines.jtk.io
Class ArrayInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by edu.mines.jtk.io.ArrayInputStream
All Implemented Interfaces:
ArrayInput, java.io.Closeable, java.io.DataInput

public class ArrayInputStream
extends java.io.FilterInputStream
implements ArrayInput

An input stream that implements ArrayInput.

Version:
2006.08.05
Author:
Dave Hale, Colorado School of Mines

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
ArrayInputStream(java.io.File file)
          Constructs an array input stream for the specified file.
ArrayInputStream(java.io.File file, java.nio.ByteOrder bo)
          Constructs an array input stream for the specified file and byte order.
ArrayInputStream(java.io.FileInputStream fis)
          Constructs an array input stream for the specified file input stream.
ArrayInputStream(java.io.FileInputStream fis, java.nio.ByteOrder bo)
          Constructs an array input stream for the specified file input stream and byte order.
ArrayInputStream(java.io.InputStream is)
          Constructs an array input stream for the specified stream.
ArrayInputStream(java.io.InputStream is, java.nio.ByteOrder bo)
          Constructs an array input stream for the specified stream and byte order.
ArrayInputStream(java.lang.String name)
          Constructs an array input stream for the specified file name.
ArrayInputStream(java.lang.String name, java.nio.ByteOrder bo)
          Constructs an array input stream for the specified file name and byte order.
 
Method Summary
 java.nio.ByteOrder getByteOrder()
          Gets the byte order for this stream.
 boolean readBoolean()
           
 byte readByte()
           
 void readBytes(byte[] v)
          Reads byte elements into a specified array.
 void readBytes(byte[][] v)
          Reads byte elements into a specified array.
 void readBytes(byte[][][] v)
          Reads byte elements into a specified array.
 void readBytes(byte[] v, int k, int n)
          Reads byte elements into a specified array.
 char readChar()
           
 void readChars(char[] v)
          Reads char elements into a specified array.
 void readChars(char[][] v)
          Reads char elements into a specified array.
 void readChars(char[][][] v)
          Reads char elements into a specified array.
 void readChars(char[] v, int k, int n)
          Reads char elements into a specified array.
 double readDouble()
           
 void readDoubles(double[] v)
          Reads double elements into a specified array.
 void readDoubles(double[][] v)
          Reads double elements into a specified array.
 void readDoubles(double[][][] v)
          Reads double elements into a specified array.
 void readDoubles(double[] v, int k, int n)
          Reads double elements into a specified array.
 float readFloat()
           
 void readFloats(float[] v)
          Reads float elements into a specified array.
 void readFloats(float[][] v)
          Reads float elements into a specified array.
 void readFloats(float[][][] v)
          Reads float elements into a specified array.
 void readFloats(float[] v, int k, int n)
          Reads float elements into a specified array.
 void readFully(byte[] b)
           
 void readFully(byte[] b, int off, int len)
           
 int readInt()
           
 void readInts(int[] v)
          Reads int elements into a specified array.
 void readInts(int[][] v)
          Reads int elements into a specified array.
 void readInts(int[][][] v)
          Reads int elements into a specified array.
 void readInts(int[] v, int k, int n)
          Reads int elements into a specified array.
 java.lang.String readLine()
           
 long readLong()
           
 void readLongs(long[] v)
          Reads long elements into a specified array.
 void readLongs(long[][] v)
          Reads long elements into a specified array.
 void readLongs(long[][][] v)
          Reads long elements into a specified array.
 void readLongs(long[] v, int k, int n)
          Reads long elements into a specified array.
 short readShort()
           
 void readShorts(short[] v)
          Reads short elements into a specified array.
 void readShorts(short[][] v)
          Reads short elements into a specified array.
 void readShorts(short[][][] v)
          Reads short elements into a specified array.
 void readShorts(short[] v, int k, int n)
          Reads short elements into a specified array.
 int readUnsignedByte()
           
 int readUnsignedShort()
           
 java.lang.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

ArrayInputStream

public ArrayInputStream(java.io.InputStream is)
Constructs an array input stream for the specified stream. The default byte order is BIG_ENDIAN.

Parameters:
is - the input stream.

ArrayInputStream

public ArrayInputStream(java.io.FileInputStream fis)
Constructs an array input stream for the specified file input stream. The file channel of the file input stream enables more efficient reads. The default byte order is BIG_ENDIAN.

Parameters:
fis - the file input stream.

ArrayInputStream

public ArrayInputStream(java.lang.String name)
                 throws java.io.FileNotFoundException
Constructs an array input stream for the specified file name. The default byte order is BIG_ENDIAN.

Parameters:
name - the file name.
Throws:
java.io.FileNotFoundException

ArrayInputStream

public ArrayInputStream(java.io.File file)
                 throws java.io.FileNotFoundException
Constructs an array input stream for the specified file. The default byte order is BIG_ENDIAN.

Parameters:
file - the file.
Throws:
java.io.FileNotFoundException

ArrayInputStream

public ArrayInputStream(java.io.InputStream is,
                        java.nio.ByteOrder bo)
Constructs an array input stream for the specified stream and byte order.

Parameters:
is - the input stream.
bo - the byte order.

ArrayInputStream

public ArrayInputStream(java.io.FileInputStream fis,
                        java.nio.ByteOrder bo)
Constructs an array input stream for the specified file input stream and byte order. The file channel of the file input stream enables more efficient reads.

Parameters:
fis - the file input stream.
bo - the byte order.

ArrayInputStream

public ArrayInputStream(java.lang.String name,
                        java.nio.ByteOrder bo)
                 throws java.io.FileNotFoundException
Constructs an array input stream for the specified file name and byte order. The default byte order is BIG_ENDIAN.

Parameters:
name - the file name.
bo - the byte order.
Throws:
java.io.FileNotFoundException

ArrayInputStream

public ArrayInputStream(java.io.File file,
                        java.nio.ByteOrder bo)
                 throws java.io.FileNotFoundException
Constructs an array input stream for the specified file and byte order. The default byte order is BIG_ENDIAN.

Parameters:
file - the file.
bo - the byte order.
Throws:
java.io.FileNotFoundException
Method Detail

getByteOrder

public java.nio.ByteOrder getByteOrder()
Gets the byte order for this stream.

Returns:
the byte order.

readFully

public void readFully(byte[] b)
               throws java.io.IOException
Specified by:
readFully in interface ArrayInput
Specified by:
readFully in interface java.io.DataInput
Throws:
java.io.IOException

readFully

public void readFully(byte[] b,
                      int off,
                      int len)
               throws java.io.IOException
Specified by:
readFully in interface ArrayInput
Specified by:
readFully in interface java.io.DataInput
Throws:
java.io.IOException

skipBytes

public int skipBytes(int n)
              throws java.io.IOException
Specified by:
skipBytes in interface ArrayInput
Specified by:
skipBytes in interface java.io.DataInput
Throws:
java.io.IOException

readBoolean

public final boolean readBoolean()
                          throws java.io.IOException
Specified by:
readBoolean in interface ArrayInput
Specified by:
readBoolean in interface java.io.DataInput
Throws:
java.io.IOException

readByte

public final byte readByte()
                    throws java.io.IOException
Specified by:
readByte in interface ArrayInput
Specified by:
readByte in interface java.io.DataInput
Throws:
java.io.IOException

readUnsignedByte

public final int readUnsignedByte()
                           throws java.io.IOException
Specified by:
readUnsignedByte in interface ArrayInput
Specified by:
readUnsignedByte in interface java.io.DataInput
Throws:
java.io.IOException

readShort

public final short readShort()
                      throws java.io.IOException
Specified by:
readShort in interface ArrayInput
Specified by:
readShort in interface java.io.DataInput
Throws:
java.io.IOException

readUnsignedShort

public final int readUnsignedShort()
                            throws java.io.IOException
Specified by:
readUnsignedShort in interface ArrayInput
Specified by:
readUnsignedShort in interface java.io.DataInput
Throws:
java.io.IOException

readChar

public final char readChar()
                    throws java.io.IOException
Specified by:
readChar in interface ArrayInput
Specified by:
readChar in interface java.io.DataInput
Throws:
java.io.IOException

readInt

public final int readInt()
                  throws java.io.IOException
Specified by:
readInt in interface ArrayInput
Specified by:
readInt in interface java.io.DataInput
Throws:
java.io.IOException

readLong

public final long readLong()
                    throws java.io.IOException
Specified by:
readLong in interface ArrayInput
Specified by:
readLong in interface java.io.DataInput
Throws:
java.io.IOException

readFloat

public final float readFloat()
                      throws java.io.IOException
Specified by:
readFloat in interface ArrayInput
Specified by:
readFloat in interface java.io.DataInput
Throws:
java.io.IOException

readDouble

public final double readDouble()
                        throws java.io.IOException
Specified by:
readDouble in interface ArrayInput
Specified by:
readDouble in interface java.io.DataInput
Throws:
java.io.IOException

readLine

public final java.lang.String readLine()
                                throws java.io.IOException
Specified by:
readLine in interface ArrayInput
Specified by:
readLine in interface java.io.DataInput
Throws:
java.io.IOException

readUTF

public final java.lang.String readUTF()
                               throws java.io.IOException
Specified by:
readUTF in interface ArrayInput
Specified by:
readUTF in interface java.io.DataInput
Throws:
java.io.IOException

readBytes

public void readBytes(byte[] v,
                      int k,
                      int n)
               throws java.io.IOException
Reads byte elements into a specified array.

Specified by:
readBytes in interface ArrayInput
Parameters:
v - the array.
k - the index of the first element to read.
n - the number of elements to read.
Throws:
java.io.IOException

readBytes

public void readBytes(byte[] v)
               throws java.io.IOException
Reads byte elements into a specified array. The array length equals the number of elements to read.

Specified by:
readBytes in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readBytes

public void readBytes(byte[][] v)
               throws java.io.IOException
Reads byte elements into a specified array. The array length equals the number of elements to read.

Specified by:
readBytes in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readBytes

public void readBytes(byte[][][] v)
               throws java.io.IOException
Reads byte elements into a specified array. The array length equals the number of elements to read.

Specified by:
readBytes in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readChars

public void readChars(char[] v,
                      int k,
                      int n)
               throws java.io.IOException
Reads char elements into a specified array.

Specified by:
readChars in interface ArrayInput
Parameters:
v - the array.
k - the index of the first element to read.
n - the number of elements to read.
Throws:
java.io.IOException

readChars

public void readChars(char[] v)
               throws java.io.IOException
Reads char elements into a specified array. The array length equals the number of elements to read.

Specified by:
readChars in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readChars

public void readChars(char[][] v)
               throws java.io.IOException
Reads char elements into a specified array. The array length equals the number of elements to read.

Specified by:
readChars in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readChars

public void readChars(char[][][] v)
               throws java.io.IOException
Reads char elements into a specified array. The array length equals the number of elements to read.

Specified by:
readChars in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readShorts

public void readShorts(short[] v,
                       int k,
                       int n)
                throws java.io.IOException
Reads short elements into a specified array.

Specified by:
readShorts in interface ArrayInput
Parameters:
v - the array.
k - the index of the first element to read.
n - the number of elements to read.
Throws:
java.io.IOException

readShorts

public void readShorts(short[] v)
                throws java.io.IOException
Reads short elements into a specified array. The array length equals the number of elements to read.

Specified by:
readShorts in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readShorts

public void readShorts(short[][] v)
                throws java.io.IOException
Reads short elements into a specified array. The array length equals the number of elements to read.

Specified by:
readShorts in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readShorts

public void readShorts(short[][][] v)
                throws java.io.IOException
Reads short elements into a specified array. The array length equals the number of elements to read.

Specified by:
readShorts in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readInts

public void readInts(int[] v,
                     int k,
                     int n)
              throws java.io.IOException
Reads int elements into a specified array.

Specified by:
readInts in interface ArrayInput
Parameters:
v - the array.
k - the index of the first element to read.
n - the number of elements to read.
Throws:
java.io.IOException

readInts

public void readInts(int[] v)
              throws java.io.IOException
Reads int elements into a specified array. The array length equals the number of elements to read.

Specified by:
readInts in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readInts

public void readInts(int[][] v)
              throws java.io.IOException
Reads int elements into a specified array. The array length equals the number of elements to read.

Specified by:
readInts in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readInts

public void readInts(int[][][] v)
              throws java.io.IOException
Reads int elements into a specified array. The array length equals the number of elements to read.

Specified by:
readInts in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readLongs

public void readLongs(long[] v,
                      int k,
                      int n)
               throws java.io.IOException
Reads long elements into a specified array.

Specified by:
readLongs in interface ArrayInput
Parameters:
v - the array.
k - the index of the first element to read.
n - the number of elements to read.
Throws:
java.io.IOException

readLongs

public void readLongs(long[] v)
               throws java.io.IOException
Reads long elements into a specified array. The array length equals the number of elements to read.

Specified by:
readLongs in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readLongs

public void readLongs(long[][] v)
               throws java.io.IOException
Reads long elements into a specified array. The array length equals the number of elements to read.

Specified by:
readLongs in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readLongs

public void readLongs(long[][][] v)
               throws java.io.IOException
Reads long elements into a specified array. The array length equals the number of elements to read.

Specified by:
readLongs in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readFloats

public void readFloats(float[] v,
                       int k,
                       int n)
                throws java.io.IOException
Reads float elements into a specified array.

Specified by:
readFloats in interface ArrayInput
Parameters:
v - the array.
k - the index of the first element to read.
n - the number of elements to read.
Throws:
java.io.IOException

readFloats

public void readFloats(float[] v)
                throws java.io.IOException
Reads float elements into a specified array. The array length equals the number of elements to read.

Specified by:
readFloats in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readFloats

public void readFloats(float[][] v)
                throws java.io.IOException
Reads float elements into a specified array. The array length equals the number of elements to read.

Specified by:
readFloats in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readFloats

public void readFloats(float[][][] v)
                throws java.io.IOException
Reads float elements into a specified array. The array length equals the number of elements to read.

Specified by:
readFloats in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readDoubles

public void readDoubles(double[] v,
                        int k,
                        int n)
                 throws java.io.IOException
Reads double elements into a specified array.

Specified by:
readDoubles in interface ArrayInput
Parameters:
v - the array.
k - the index of the first element to read.
n - the number of elements to read.
Throws:
java.io.IOException

readDoubles

public void readDoubles(double[] v)
                 throws java.io.IOException
Reads double elements into a specified array. The array length equals the number of elements to read.

Specified by:
readDoubles in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readDoubles

public void readDoubles(double[][] v)
                 throws java.io.IOException
Reads double elements into a specified array. The array length equals the number of elements to read.

Specified by:
readDoubles in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException

readDoubles

public void readDoubles(double[][][] v)
                 throws java.io.IOException
Reads double elements into a specified array. The array length equals the number of elements to read.

Specified by:
readDoubles in interface ArrayInput
Parameters:
v - the array.
Throws:
java.io.IOException