edu.mines.jtk.io
Class ArrayOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by edu.mines.jtk.io.ArrayOutputStream
All Implemented Interfaces:
ArrayOutput, java.io.Closeable, java.io.DataOutput, java.io.Flushable

public class ArrayOutputStream
extends java.io.FilterOutputStream
implements ArrayOutput

An output stream that implements ArrayOutput.

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

Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
ArrayOutputStream(java.io.File file)
          Constructs an array output stream for the specified file.
ArrayOutputStream(java.io.File file, java.nio.ByteOrder bo)
          Constructs an array output stream for the specified file and byte order.
ArrayOutputStream(java.io.FileOutputStream fos)
          Constructs an array output stream for the specified file output stream.
ArrayOutputStream(java.io.FileOutputStream fos, java.nio.ByteOrder bo)
          Constructs an array output stream for the specified file output stream and byte order.
ArrayOutputStream(java.io.OutputStream os)
          Constructs an array output stream for the specified stream.
ArrayOutputStream(java.io.OutputStream os, java.nio.ByteOrder bo)
          Constructs an array output stream for the specified stream and byte order.
ArrayOutputStream(java.lang.String name)
          Constructs an array output stream for the specified file name.
ArrayOutputStream(java.lang.String name, java.nio.ByteOrder bo)
          Constructs an array output stream for the specified file name and byte order.
 
Method Summary
 java.nio.ByteOrder getByteOrder()
          Gets the byte order for this stream.
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 void writeBoolean(boolean v)
           
 void writeByte(int v)
           
 void writeBytes(byte[] v)
          Writes byte elements from a specified array.
 void writeBytes(byte[][] v)
          Writes byte elements from a specified array.
 void writeBytes(byte[][][] v)
          Writes byte elements from a specified array.
 void writeBytes(byte[] v, int k, int n)
          Writes byte elements from a specified array.
 void writeBytes(java.lang.String s)
           
 void writeChar(int v)
           
 void writeChars(char[] v)
          Writes char elements from a specified array.
 void writeChars(char[][] v)
          Writes char elements from a specified array.
 void writeChars(char[][][] v)
          Writes char elements from a specified array.
 void writeChars(char[] v, int k, int n)
          Writes char elements from a specified array.
 void writeChars(java.lang.String s)
           
 void writeDouble(double v)
           
 void writeDoubles(double[] v)
          Writes double elements from a specified array.
 void writeDoubles(double[][] v)
          Writes double elements from a specified array.
 void writeDoubles(double[][][] v)
          Writes double elements from a specified array.
 void writeDoubles(double[] v, int k, int n)
          Writes double elements from a specified array.
 void writeFloat(float v)
           
 void writeFloats(float[] v)
          Writes float elements from a specified array.
 void writeFloats(float[][] v)
          Writes float elements from a specified array.
 void writeFloats(float[][][] v)
          Writes float elements from a specified array.
 void writeFloats(float[] v, int k, int n)
          Writes float elements from a specified array.
 void writeInt(int v)
           
 void writeInts(int[] v)
          Writes int elements from a specified array.
 void writeInts(int[][] v)
          Writes int elements from a specified array.
 void writeInts(int[][][] v)
          Writes int elements from a specified array.
 void writeInts(int[] v, int k, int n)
          Writes int elements from a specified array.
 void writeLong(long v)
           
 void writeLongs(long[] v)
          Writes long elements from a specified array.
 void writeLongs(long[][] v)
          Writes long elements from a specified array.
 void writeLongs(long[][][] v)
          Writes long elements from a specified array.
 void writeLongs(long[] v, int k, int n)
          Writes long elements from a specified array.
 void writeShort(int v)
           
 void writeShorts(short[] v)
          Writes shorts elements from a specified array.
 void writeShorts(short[][] v)
          Writes short elements from a specified array.
 void writeShorts(short[][][] v)
          Writes short elements from a specified array.
 void writeShorts(short[] v, int k, int n)
          Writes short elements from a specified array.
 void writeUTF(java.lang.String s)
           
 
Methods inherited from class java.io.FilterOutputStream
close, flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayOutputStream

public ArrayOutputStream(java.io.OutputStream os)
Constructs an array output stream for the specified stream. The default byte order is BIG_ENDIAN.

Parameters:
os - the output stream.

ArrayOutputStream

public ArrayOutputStream(java.io.FileOutputStream fos)
Constructs an array output stream for the specified file output stream. The file channel of the file output stream enables more efficient writes. The default byte order is BIG_ENDIAN.

Parameters:
fos - the file output stream.

ArrayOutputStream

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

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

ArrayOutputStream

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

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

ArrayOutputStream

public ArrayOutputStream(java.io.OutputStream os,
                         java.nio.ByteOrder bo)
Constructs an array output stream for the specified stream and byte order.

Parameters:
os - the output stream.
bo - the byte order.

ArrayOutputStream

public ArrayOutputStream(java.io.FileOutputStream fos,
                         java.nio.ByteOrder bo)
Constructs an array output stream for the specified file output stream and byte order. The file channel of the file output stream enables more efficient writes.

Parameters:
fos - the file output stream.
bo - the byte order.

ArrayOutputStream

public ArrayOutputStream(java.lang.String name,
                         java.nio.ByteOrder bo)
                  throws java.io.FileNotFoundException
Constructs an array output 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

ArrayOutputStream

public ArrayOutputStream(java.io.File file,
                         java.nio.ByteOrder bo)
                  throws java.io.FileNotFoundException
Constructs an array output 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.

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in interface ArrayOutput
Specified by:
write in interface java.io.DataOutput
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Specified by:
write in interface ArrayOutput
Specified by:
write in interface java.io.DataOutput
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Specified by:
write in interface ArrayOutput
Specified by:
write in interface java.io.DataOutput
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

writeBoolean

public void writeBoolean(boolean v)
                  throws java.io.IOException
Specified by:
writeBoolean in interface ArrayOutput
Specified by:
writeBoolean in interface java.io.DataOutput
Throws:
java.io.IOException

writeByte

public void writeByte(int v)
               throws java.io.IOException
Specified by:
writeByte in interface ArrayOutput
Specified by:
writeByte in interface java.io.DataOutput
Throws:
java.io.IOException

writeShort

public void writeShort(int v)
                throws java.io.IOException
Specified by:
writeShort in interface ArrayOutput
Specified by:
writeShort in interface java.io.DataOutput
Throws:
java.io.IOException

writeChar

public void writeChar(int v)
               throws java.io.IOException
Specified by:
writeChar in interface ArrayOutput
Specified by:
writeChar in interface java.io.DataOutput
Throws:
java.io.IOException

writeInt

public void writeInt(int v)
              throws java.io.IOException
Specified by:
writeInt in interface ArrayOutput
Specified by:
writeInt in interface java.io.DataOutput
Throws:
java.io.IOException

writeLong

public void writeLong(long v)
               throws java.io.IOException
Specified by:
writeLong in interface ArrayOutput
Specified by:
writeLong in interface java.io.DataOutput
Throws:
java.io.IOException

writeFloat

public void writeFloat(float v)
                throws java.io.IOException
Specified by:
writeFloat in interface ArrayOutput
Specified by:
writeFloat in interface java.io.DataOutput
Throws:
java.io.IOException

writeDouble

public void writeDouble(double v)
                 throws java.io.IOException
Specified by:
writeDouble in interface ArrayOutput
Specified by:
writeDouble in interface java.io.DataOutput
Throws:
java.io.IOException

writeBytes

public void writeBytes(java.lang.String s)
                throws java.io.IOException
Specified by:
writeBytes in interface ArrayOutput
Specified by:
writeBytes in interface java.io.DataOutput
Throws:
java.io.IOException

writeChars

public void writeChars(java.lang.String s)
                throws java.io.IOException
Specified by:
writeChars in interface ArrayOutput
Specified by:
writeChars in interface java.io.DataOutput
Throws:
java.io.IOException

writeUTF

public void writeUTF(java.lang.String s)
              throws java.io.IOException
Specified by:
writeUTF in interface ArrayOutput
Specified by:
writeUTF in interface java.io.DataOutput
Throws:
java.io.IOException

writeBytes

public void writeBytes(byte[] v,
                       int k,
                       int n)
                throws java.io.IOException
Writes byte elements from a specified array.

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

writeBytes

public void writeBytes(byte[] v)
                throws java.io.IOException
Writes byte elements from a specified array. The array length equals the number of elements to write.

Specified by:
writeBytes in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeBytes

public void writeBytes(byte[][] v)
                throws java.io.IOException
Writes byte elements from a specified array.

Specified by:
writeBytes in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeBytes

public void writeBytes(byte[][][] v)
                throws java.io.IOException
Writes byte elements from a specified array.

Specified by:
writeBytes in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeChars

public void writeChars(char[] v,
                       int k,
                       int n)
                throws java.io.IOException
Writes char elements from a specified array.

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

writeChars

public void writeChars(char[] v)
                throws java.io.IOException
Writes char elements from a specified array. The array length equals the number of elements to write.

Specified by:
writeChars in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeChars

public void writeChars(char[][] v)
                throws java.io.IOException
Writes char elements from a specified array.

Specified by:
writeChars in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeChars

public void writeChars(char[][][] v)
                throws java.io.IOException
Writes char elements from a specified array.

Specified by:
writeChars in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeShorts

public void writeShorts(short[] v,
                        int k,
                        int n)
                 throws java.io.IOException
Writes short elements from a specified array.

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

writeShorts

public void writeShorts(short[] v)
                 throws java.io.IOException
Writes shorts elements from a specified array. The array length equals the number of elements to write.

Specified by:
writeShorts in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeShorts

public void writeShorts(short[][] v)
                 throws java.io.IOException
Writes short elements from a specified array.

Specified by:
writeShorts in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeShorts

public void writeShorts(short[][][] v)
                 throws java.io.IOException
Writes short elements from a specified array.

Specified by:
writeShorts in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeInts

public void writeInts(int[] v,
                      int k,
                      int n)
               throws java.io.IOException
Writes int elements from a specified array.

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

writeInts

public void writeInts(int[] v)
               throws java.io.IOException
Writes int elements from a specified array. The array length equals the number of elements to write.

Specified by:
writeInts in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeInts

public void writeInts(int[][] v)
               throws java.io.IOException
Writes int elements from a specified array.

Specified by:
writeInts in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeInts

public void writeInts(int[][][] v)
               throws java.io.IOException
Writes int elements from a specified array.

Specified by:
writeInts in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeLongs

public void writeLongs(long[] v,
                       int k,
                       int n)
                throws java.io.IOException
Writes long elements from a specified array.

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

writeLongs

public void writeLongs(long[] v)
                throws java.io.IOException
Writes long elements from a specified array. The array length equals the number of elements to write.

Specified by:
writeLongs in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeLongs

public void writeLongs(long[][] v)
                throws java.io.IOException
Writes long elements from a specified array.

Specified by:
writeLongs in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeLongs

public void writeLongs(long[][][] v)
                throws java.io.IOException
Writes long elements from a specified array.

Specified by:
writeLongs in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeFloats

public void writeFloats(float[] v,
                        int k,
                        int n)
                 throws java.io.IOException
Writes float elements from a specified array.

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

writeFloats

public void writeFloats(float[] v)
                 throws java.io.IOException
Writes float elements from a specified array. The array length equals the number of elements to write.

Specified by:
writeFloats in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeFloats

public void writeFloats(float[][] v)
                 throws java.io.IOException
Writes float elements from a specified array.

Specified by:
writeFloats in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeFloats

public void writeFloats(float[][][] v)
                 throws java.io.IOException
Writes float elements from a specified array.

Specified by:
writeFloats in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeDoubles

public void writeDoubles(double[] v,
                         int k,
                         int n)
                  throws java.io.IOException
Writes double elements from a specified array.

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

writeDoubles

public void writeDoubles(double[] v)
                  throws java.io.IOException
Writes double elements from a specified array. The array length equals the number of elements to write.

Specified by:
writeDoubles in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeDoubles

public void writeDoubles(double[][] v)
                  throws java.io.IOException
Writes double elements from a specified array.

Specified by:
writeDoubles in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException

writeDoubles

public void writeDoubles(double[][][] v)
                  throws java.io.IOException
Writes double elements from a specified array.

Specified by:
writeDoubles in interface ArrayOutput
Parameters:
v - the array.
Throws:
java.io.IOException