|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.mines.jtk.io.ArrayFile
public class ArrayFile
An array file expands the capabilities of RandomAccessFile.
Specifically, an array file has methods for efficiently reading and writing
arrays of primitive values, such as ints and floats. Also, array files may
be read or written with either BIG_ENDIAN or LITTLE_ENDIAN byte orders.
An array file implements the interfaces ArrayInput and
ArrayOutput, which extend the standard Java interfaces
DataInput and DataOutput, respectively.
An array file can be constructed by specifying a file name and access mode
(as for a RandomAccessFile). Alternatively, an array file
can be constructed from an existing RandomAccessFile.
| Constructor Summary | |
|---|---|
ArrayFile(java.io.File file,
java.lang.String mode)
Constructs an array file with specified file and access mode. |
|
ArrayFile(java.io.File file,
java.lang.String mode,
java.nio.ByteOrder bor,
java.nio.ByteOrder bow)
Constructs an array file with specified file, access mode, and byte orders. |
|
ArrayFile(java.io.RandomAccessFile raf,
java.nio.ByteOrder bor,
java.nio.ByteOrder bow)
Constructs an array file for a specified random-access file and byte orders. |
|
ArrayFile(java.lang.String name,
java.lang.String mode)
Constructs an array file with specified name and access mode. |
|
ArrayFile(java.lang.String name,
java.lang.String mode,
java.nio.ByteOrder bor,
java.nio.ByteOrder bow)
Constructs an array file with specified name, access mode, and byte orders. |
|
| Method Summary | |
|---|---|
void |
close()
Closes this data file, releasing any associated system resources. |
java.nio.ByteOrder |
getByteOrderRead()
Gets the byte order for reading data. |
java.nio.ByteOrder |
getByteOrderWrite()
Gets the byte order for writing data. |
long |
getFilePointer()
Gets the file pointer (byte offset) for this file. |
long |
length()
Returns the length of this file. |
int |
read()
Reads a byte value from this file. |
int |
read(byte[] b)
Reads up to b.length bytes from this file. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes from this file. |
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()
|
void |
seek(long off)
Sets the file pointer (byte offset) for this file. |
void |
setLength(long newLength)
Sets the length of this file. |
int |
skipBytes(int n)
|
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.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ArrayFile(java.lang.String name,
java.lang.String mode)
throws java.io.FileNotFoundException
name - the file name.mode - the access mode; "r", "rw", "rws", or "rwd".
java.io.FileNotFoundException
public ArrayFile(java.io.File file,
java.lang.String mode)
throws java.io.FileNotFoundException
file - the file.mode - the access mode; "r", "rw", "rws", or "rwd".
java.io.FileNotFoundException
public ArrayFile(java.lang.String name,
java.lang.String mode,
java.nio.ByteOrder bor,
java.nio.ByteOrder bow)
throws java.io.FileNotFoundException
name - the file name.mode - the access mode; "r", "rw", "rws", or "rwd".bor - the byte order for reading.bow - the byte order for writing.
java.io.FileNotFoundException
public ArrayFile(java.io.File file,
java.lang.String mode,
java.nio.ByteOrder bor,
java.nio.ByteOrder bow)
throws java.io.FileNotFoundException
file - the file.mode - the access mode; "r", "rw", "rws", or "rwd".bor - the byte order for reading.bow - the byte order for writing.
java.io.FileNotFoundException
public ArrayFile(java.io.RandomAccessFile raf,
java.nio.ByteOrder bor,
java.nio.ByteOrder bow)
raf - the random-access file.bor - the byte order for reading.bow - the byte order for writing.| Method Detail |
|---|
public java.nio.ByteOrder getByteOrderRead()
public java.nio.ByteOrder getByteOrderWrite()
public int read()
throws java.io.IOException
java.io.IOException
public int read(byte[] b)
throws java.io.IOException
b - array into which to read bytes.
java.io.IOException
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
b - array into which to read bytes.off - array index of first byte to read.len - the number of bytes to read.
java.io.IOException
public void readFully(byte[] b)
throws java.io.IOException
readFully in interface ArrayInputreadFully in interface java.io.DataInputjava.io.IOException
public void readFully(byte[] b,
int off,
int len)
throws java.io.IOException
readFully in interface ArrayInputreadFully in interface java.io.DataInputjava.io.IOException
public int skipBytes(int n)
throws java.io.IOException
skipBytes in interface ArrayInputskipBytes in interface java.io.DataInputjava.io.IOException
public void write(int b)
throws java.io.IOException
write in interface ArrayOutputwrite in interface java.io.DataOutputjava.io.IOException
public void write(byte[] b)
throws java.io.IOException
write in interface ArrayOutputwrite in interface java.io.DataOutputjava.io.IOException
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
write in interface ArrayOutputwrite in interface java.io.DataOutputjava.io.IOException
public long getFilePointer()
throws java.io.IOException
java.io.IOException
public void seek(long off)
throws java.io.IOException
The offset may be set beyond the end of the file. Setting the offset beyond the end of the file does not increase the file length. The file length increases only by writing beyond the end of the file.
off - the file pointer, the offset in bytes from the
beginning of the file.
java.io.IOException
public long length()
throws java.io.IOException
java.io.IOException
public void setLength(long newLength)
throws java.io.IOException
If the current file length is less than the specified new length, then this file will extended. The content of the extended portion is undefined.
newLength - the new length.
java.io.IOException
public void close()
throws java.io.IOException
close in interface java.io.Closeablejava.io.IOException
public final boolean readBoolean()
throws java.io.IOException
readBoolean in interface ArrayInputreadBoolean in interface java.io.DataInputjava.io.IOException
public final byte readByte()
throws java.io.IOException
readByte in interface ArrayInputreadByte in interface java.io.DataInputjava.io.IOException
public final int readUnsignedByte()
throws java.io.IOException
readUnsignedByte in interface ArrayInputreadUnsignedByte in interface java.io.DataInputjava.io.IOException
public final short readShort()
throws java.io.IOException
readShort in interface ArrayInputreadShort in interface java.io.DataInputjava.io.IOException
public final int readUnsignedShort()
throws java.io.IOException
readUnsignedShort in interface ArrayInputreadUnsignedShort in interface java.io.DataInputjava.io.IOException
public final char readChar()
throws java.io.IOException
readChar in interface ArrayInputreadChar in interface java.io.DataInputjava.io.IOException
public final int readInt()
throws java.io.IOException
readInt in interface ArrayInputreadInt in interface java.io.DataInputjava.io.IOException
public final long readLong()
throws java.io.IOException
readLong in interface ArrayInputreadLong in interface java.io.DataInputjava.io.IOException
public final float readFloat()
throws java.io.IOException
readFloat in interface ArrayInputreadFloat in interface java.io.DataInputjava.io.IOException
public final double readDouble()
throws java.io.IOException
readDouble in interface ArrayInputreadDouble in interface java.io.DataInputjava.io.IOException
public final java.lang.String readLine()
throws java.io.IOException
readLine in interface ArrayInputreadLine in interface java.io.DataInputjava.io.IOException
public final java.lang.String readUTF()
throws java.io.IOException
readUTF in interface ArrayInputreadUTF in interface java.io.DataInputjava.io.IOException
public void writeBoolean(boolean v)
throws java.io.IOException
writeBoolean in interface ArrayOutputwriteBoolean in interface java.io.DataOutputjava.io.IOException
public void writeByte(int v)
throws java.io.IOException
writeByte in interface ArrayOutputwriteByte in interface java.io.DataOutputjava.io.IOException
public void writeShort(int v)
throws java.io.IOException
writeShort in interface ArrayOutputwriteShort in interface java.io.DataOutputjava.io.IOException
public void writeChar(int v)
throws java.io.IOException
writeChar in interface ArrayOutputwriteChar in interface java.io.DataOutputjava.io.IOException
public void writeInt(int v)
throws java.io.IOException
writeInt in interface ArrayOutputwriteInt in interface java.io.DataOutputjava.io.IOException
public void writeLong(long v)
throws java.io.IOException
writeLong in interface ArrayOutputwriteLong in interface java.io.DataOutputjava.io.IOException
public void writeFloat(float v)
throws java.io.IOException
writeFloat in interface ArrayOutputwriteFloat in interface java.io.DataOutputjava.io.IOException
public void writeDouble(double v)
throws java.io.IOException
writeDouble in interface ArrayOutputwriteDouble in interface java.io.DataOutputjava.io.IOException
public void writeBytes(java.lang.String s)
throws java.io.IOException
writeBytes in interface ArrayOutputwriteBytes in interface java.io.DataOutputjava.io.IOException
public void writeChars(java.lang.String s)
throws java.io.IOException
writeChars in interface ArrayOutputwriteChars in interface java.io.DataOutputjava.io.IOException
public void writeUTF(java.lang.String s)
throws java.io.IOException
writeUTF in interface ArrayOutputwriteUTF in interface java.io.DataOutputjava.io.IOException
public void readBytes(byte[] v,
int k,
int n)
throws java.io.IOException
readBytes in interface ArrayInputv - the array.k - the index of the first element to read.n - the number of elements to read.
java.io.IOException
public void readBytes(byte[] v)
throws java.io.IOException
readBytes in interface ArrayInputv - the array.
java.io.IOException
public void readBytes(byte[][] v)
throws java.io.IOException
readBytes in interface ArrayInputv - the array.
java.io.IOException
public void readBytes(byte[][][] v)
throws java.io.IOException
readBytes in interface ArrayInputv - the array.
java.io.IOException
public void readChars(char[] v,
int k,
int n)
throws java.io.IOException
readChars in interface ArrayInputv - the array.k - the index of the first element to read.n - the number of elements to read.
java.io.IOException
public void readChars(char[] v)
throws java.io.IOException
readChars in interface ArrayInputv - the array.
java.io.IOException
public void readChars(char[][] v)
throws java.io.IOException
readChars in interface ArrayInputv - the array.
java.io.IOException
public void readChars(char[][][] v)
throws java.io.IOException
readChars in interface ArrayInputv - the array.
java.io.IOException
public void readShorts(short[] v,
int k,
int n)
throws java.io.IOException
readShorts in interface ArrayInputv - the array.k - the index of the first element to read.n - the number of elements to read.
java.io.IOException
public void readShorts(short[] v)
throws java.io.IOException
readShorts in interface ArrayInputv - the array.
java.io.IOException
public void readShorts(short[][] v)
throws java.io.IOException
readShorts in interface ArrayInputv - the array.
java.io.IOException
public void readShorts(short[][][] v)
throws java.io.IOException
readShorts in interface ArrayInputv - the array.
java.io.IOException
public void readInts(int[] v,
int k,
int n)
throws java.io.IOException
readInts in interface ArrayInputv - the array.k - the index of the first element to read.n - the number of elements to read.
java.io.IOException
public void readInts(int[] v)
throws java.io.IOException
readInts in interface ArrayInputv - the array.
java.io.IOException
public void readInts(int[][] v)
throws java.io.IOException
readInts in interface ArrayInputv - the array.
java.io.IOException
public void readInts(int[][][] v)
throws java.io.IOException
readInts in interface ArrayInputv - the array.
java.io.IOException
public void readLongs(long[] v,
int k,
int n)
throws java.io.IOException
readLongs in interface ArrayInputv - the array.k - the index of the first element to read.n - the number of elements to read.
java.io.IOException
public void readLongs(long[] v)
throws java.io.IOException
readLongs in interface ArrayInputv - the array.
java.io.IOException
public void readLongs(long[][] v)
throws java.io.IOException
readLongs in interface ArrayInputv - the array.
java.io.IOException
public void readLongs(long[][][] v)
throws java.io.IOException
readLongs in interface ArrayInputv - the array.
java.io.IOException
public void readFloats(float[] v,
int k,
int n)
throws java.io.IOException
readFloats in interface ArrayInputv - the array.k - the index of the first element to read.n - the number of elements to read.
java.io.IOException
public void readFloats(float[] v)
throws java.io.IOException
readFloats in interface ArrayInputv - the array.
java.io.IOException
public void readFloats(float[][] v)
throws java.io.IOException
readFloats in interface ArrayInputv - the array.
java.io.IOException
public void readFloats(float[][][] v)
throws java.io.IOException
readFloats in interface ArrayInputv - the array.
java.io.IOException
public void readDoubles(double[] v,
int k,
int n)
throws java.io.IOException
readDoubles in interface ArrayInputv - the array.k - the index of the first element to read.n - the number of elements to read.
java.io.IOException
public void readDoubles(double[] v)
throws java.io.IOException
readDoubles in interface ArrayInputv - the array.
java.io.IOException
public void readDoubles(double[][] v)
throws java.io.IOException
readDoubles in interface ArrayInputv - the array.
java.io.IOException
public void readDoubles(double[][][] v)
throws java.io.IOException
readDoubles in interface ArrayInputv - the array.
java.io.IOException
public void writeBytes(byte[] v,
int k,
int n)
throws java.io.IOException
writeBytes in interface ArrayOutputv - the array.k - the index of the first element to write.n - the number of elements to write.
java.io.IOException
public void writeBytes(byte[] v)
throws java.io.IOException
writeBytes in interface ArrayOutputv - the array.
java.io.IOException
public void writeBytes(byte[][] v)
throws java.io.IOException
writeBytes in interface ArrayOutputv - the array.
java.io.IOException
public void writeBytes(byte[][][] v)
throws java.io.IOException
writeBytes in interface ArrayOutputv - the array.
java.io.IOException
public void writeChars(char[] v,
int k,
int n)
throws java.io.IOException
writeChars in interface ArrayOutputv - the array.k - the index of the first element to write.n - the number of elements to write.
java.io.IOException
public void writeChars(char[] v)
throws java.io.IOException
writeChars in interface ArrayOutputv - the array.
java.io.IOException
public void writeChars(char[][] v)
throws java.io.IOException
writeChars in interface ArrayOutputv - the array.
java.io.IOException
public void writeChars(char[][][] v)
throws java.io.IOException
writeChars in interface ArrayOutputv - the array.
java.io.IOException
public void writeShorts(short[] v,
int k,
int n)
throws java.io.IOException
writeShorts in interface ArrayOutputv - the array.k - the index of the first element to write.n - the number of elements to write.
java.io.IOException
public void writeShorts(short[] v)
throws java.io.IOException
writeShorts in interface ArrayOutputv - the array.
java.io.IOException
public void writeShorts(short[][] v)
throws java.io.IOException
writeShorts in interface ArrayOutputv - the array.
java.io.IOException
public void writeShorts(short[][][] v)
throws java.io.IOException
writeShorts in interface ArrayOutputv - the array.
java.io.IOException
public void writeInts(int[] v,
int k,
int n)
throws java.io.IOException
writeInts in interface ArrayOutputv - the array.k - the index of the first element to write.n - the number of elements to write.
java.io.IOException
public void writeInts(int[] v)
throws java.io.IOException
writeInts in interface ArrayOutputv - the array.
java.io.IOException
public void writeInts(int[][] v)
throws java.io.IOException
writeInts in interface ArrayOutputv - the array.
java.io.IOException
public void writeInts(int[][][] v)
throws java.io.IOException
writeInts in interface ArrayOutputv - the array.
java.io.IOException
public void writeLongs(long[] v,
int k,
int n)
throws java.io.IOException
writeLongs in interface ArrayOutputv - the array.k - the index of the first element to write.n - the number of elements to write.
java.io.IOException
public void writeLongs(long[] v)
throws java.io.IOException
writeLongs in interface ArrayOutputv - the array.
java.io.IOException
public void writeLongs(long[][] v)
throws java.io.IOException
writeLongs in interface ArrayOutputv - the array.
java.io.IOException
public void writeLongs(long[][][] v)
throws java.io.IOException
writeLongs in interface ArrayOutputv - the array.
java.io.IOException
public void writeFloats(float[] v,
int k,
int n)
throws java.io.IOException
writeFloats in interface ArrayOutputv - the array.k - the index of the first element to write.n - the number of elements to write.
java.io.IOException
public void writeFloats(float[] v)
throws java.io.IOException
writeFloats in interface ArrayOutputv - the array.
java.io.IOException
public void writeFloats(float[][] v)
throws java.io.IOException
writeFloats in interface ArrayOutputv - the array.
java.io.IOException
public void writeFloats(float[][][] v)
throws java.io.IOException
writeFloats in interface ArrayOutputv - the array.
java.io.IOException
public void writeDoubles(double[] v,
int k,
int n)
throws java.io.IOException
writeDoubles in interface ArrayOutputv - the array.k - the index of the first element to write.n - the number of elements to write.
java.io.IOException
public void writeDoubles(double[] v)
throws java.io.IOException
writeDoubles in interface ArrayOutputv - the array.
java.io.IOException
public void writeDoubles(double[][] v)
throws java.io.IOException
writeDoubles in interface ArrayOutputv - the array.
java.io.IOException
public void writeDoubles(double[][][] v)
throws java.io.IOException
writeDoubles in interface ArrayOutputv - the array.
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||