Package nom.tam.util
Class BufferedFile
- java.lang.Object
-
- nom.tam.util.BufferedFile
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.DataInput
,java.io.DataOutput
,java.lang.AutoCloseable
,ArrayDataInput
,ArrayDataOutput
,FitsIO
,RandomAccess
public class BufferedFile extends java.lang.Object implements ArrayDataOutput, RandomAccess
-
-
Field Summary
Fields Modifier and Type Field Description private int
bufferMarker
marker position in the dataBuffer.buffer.private BufferPointer
bufferPointer
private BufferDecoder
dataDecoder
private BufferEncoder
dataEncoder
private static int
DEFAULT_BUFFER_SIZE
private boolean
doingInput
Is the dataBuffer.buffer being used for input or outputprivate long
fileOffset
The offset of the beginning of the current dataBuffer.bufferprivate static java.util.logging.Logger
LOG
private java.io.RandomAccessFile
randomAccessFile
The underlying access to the file system-
Fields inherited from interface nom.tam.util.FitsIO
BITS_OF_1_BYTE, BITS_OF_2_BYTES, BITS_OF_3_BYTES, BITS_OF_4_BYTES, BITS_OF_5_BYTES, BITS_OF_6_BYTES, BITS_OF_7_BYTES, BYTE_1_OF_LONG_MASK, BYTE_2_OF_LONG_MASK, BYTE_3_OF_LONG_MASK, BYTE_4_OF_LONG_MASK, BYTE_MASK, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_FLOAT, BYTES_IN_INTEGER, BYTES_IN_LONG, BYTES_IN_SHORT, HIGH_INTEGER_MASK, INTEGER_MASK, SHORT_MASK, SHORT_OF_LONG_MASK
-
-
Constructor Summary
Constructors Constructor Description BufferedFile(java.io.File file)
Create a buffered file from a File descriptorBufferedFile(java.io.File file, java.lang.String mode)
Create a buffered file from a File descriptorBufferedFile(java.io.File file, java.lang.String mode, int bufferSize)
Create a buffered file from a file descriptorBufferedFile(java.lang.String filename)
Create a read-only buffered fileBufferedFile(java.lang.String filename, java.lang.String mode)
Create a buffered file with the given mode.BufferedFile(java.lang.String filename, java.lang.String mode, int bufferSize)
Create a buffered file with the given mode and a specified dataBuffer.buffer size.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private void
checkBuffer(int needBytes)
This should only be used when a small number of bytes is required (substantially smaller than bufferSize.void
close()
protected void
finalize()
void
flush()
Flush the output bufferjava.nio.channels.FileChannel
getChannel()
Get the channel associated with this file.java.io.FileDescriptor
getFD()
Get the file descriptor associated with this stream.long
getFilePointer()
Get the current offset into the file.long
length()
void
mark(int readlimit)
See the general contract of themark
method ofInputStream
.private void
needBuffer(int need)
int
read()
int
read(boolean[] b)
Read an array of boolean's.int
read(boolean[] b, int start, int length)
Read a segment of an array of boolean's.int
read(byte[] buf)
Read an array of byte's.int
read(byte[] buf, int offset, int len)
Read a segment of an array of byte's.int
read(char[] c)
Read an array of char's.int
read(char[] c, int start, int length)
Read a segment of an array of char's.int
read(double[] d)
Read an array of double's.int
read(double[] d, int start, int length)
Read a segment of an array of double's.int
read(float[] f)
Read an array of float's.int
read(float[] f, int start, int length)
Read a segment of an array of float's.int
read(int[] i)
Read an array of int's.int
read(int[] i, int start, int length)
Read a segment of an array of int's.int
read(long[] l)
Read a segment of an array of long's.int
read(long[] l, int start, int length)
Read a segment of an array of long's.int
read(short[] s)
Read an array of short's.int
read(short[] s, int start, int length)
Read a segment of an array of short's.int
readArray(java.lang.Object o)
Deprecated.boolean
readBoolean()
byte
readByte()
char
readChar()
double
readDouble()
float
readFloat()
void
readFully(byte[] b)
void
readFully(byte[] b, int off, int len)
Read a buffer and signal an EOF if the requested elements cannot be read.int
readInt()
long
readLArray(java.lang.Object o)
Read an object.java.lang.String
readLine()
Read a line of input.long
readLong()
short
readShort()
int
readUnsignedByte()
int
readUnsignedShort()
java.lang.String
readUTF()
void
reset()
See the general contract of thereset
method ofInputStream
.void
seek(long offsetFromStart)
Move to a specified location in the stream.void
setLength(long newLength)
Set the length of the file.long
skip(long offset)
Skip the number of bytes.void
skipAllBytes(int toSkip)
Skip the number of bytes.void
skipAllBytes(long toSkip)
Skip the number of bytes.int
skipBytes(int n)
void
write(boolean[] b)
Write an array of boolean's.void
write(boolean[] b, int start, int length)
Write a segment of an array of boolean's.void
write(byte[] buf)
void
write(byte[] buf, int offset, int length)
void
write(char[] c)
Write an array of char's.void
write(char[] c, int start, int length)
Write a segment of an array of char's.void
write(double[] d)
Write an array of double's.void
write(double[] d, int start, int length)
Write a segment of an array of double's.void
write(float[] f)
Write an array of float's.void
write(float[] f, int start, int length)
Write a segment of an array of float's.void
write(int buf)
void
write(int[] i)
Write an array of int's.void
write(int[] i, int start, int length)
Write a segment of an array of int's.void
write(long[] l)
Write an array of longs.void
write(long[] l, int start, int length)
Write a segment of an array of longs.void
write(short[] s)
Write an array of shorts.void
write(short[] s, int start, int length)
Write a segment of an array of shorts.void
write(java.lang.String[] s)
Write an array of Strings.void
write(java.lang.String[] s, int start, int length)
Write a segment of an array of Strings.void
writeArray(java.lang.Object o)
This routine provides efficient writing of arrays of any primitive type.void
writeBoolean(boolean b)
void
writeByte(int b)
void
writeBytes(java.lang.String s)
void
writeChar(int c)
void
writeChars(java.lang.String s)
void
writeDouble(double d)
void
writeFloat(float f)
void
writeInt(int i)
void
writeLong(long l)
void
writeShort(int s)
void
writeUTF(java.lang.String s)
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
LOG
private static final java.util.logging.Logger LOG
-
bufferPointer
private final BufferPointer bufferPointer
-
dataDecoder
private final BufferDecoder dataDecoder
-
dataEncoder
private final BufferEncoder dataEncoder
-
randomAccessFile
private final java.io.RandomAccessFile randomAccessFile
The underlying access to the file system
-
fileOffset
private long fileOffset
The offset of the beginning of the current dataBuffer.buffer
-
doingInput
private boolean doingInput
Is the dataBuffer.buffer being used for input or output
-
bufferMarker
private int bufferMarker
marker position in the dataBuffer.buffer.
-
-
Constructor Detail
-
BufferedFile
public BufferedFile(java.io.File file) throws java.io.IOException
Create a buffered file from a File descriptor- Parameters:
file
- the file to open.- Throws:
java.io.IOException
- if the file could not be opened
-
BufferedFile
public BufferedFile(java.io.File file, java.lang.String mode) throws java.io.IOException
Create a buffered file from a File descriptor- Parameters:
file
- the file to open.mode
- the mode to open the file in- Throws:
java.io.IOException
- if the file could not be opened
-
BufferedFile
public BufferedFile(java.io.File file, java.lang.String mode, int bufferSize) throws java.io.IOException
Create a buffered file from a file descriptor- Parameters:
file
- the file to open.mode
- the mode to open the file inbufferSize
- the dataBuffer.buffer size to use- Throws:
java.io.IOException
- if the file could not be opened
-
BufferedFile
public BufferedFile(java.lang.String filename) throws java.io.IOException
Create a read-only buffered file- Parameters:
filename
- the name of the file to open- Throws:
java.io.IOException
- if the file could not be opened
-
BufferedFile
public BufferedFile(java.lang.String filename, java.lang.String mode) throws java.io.IOException
Create a buffered file with the given mode.- Parameters:
filename
- The file to be accessed.mode
- A string composed of "r" and "w" for read and write access.- Throws:
java.io.IOException
- if the file could not be opened
-
BufferedFile
public BufferedFile(java.lang.String filename, java.lang.String mode, int bufferSize) throws java.io.IOException
Create a buffered file with the given mode and a specified dataBuffer.buffer size.- Parameters:
filename
- The file to be accessed.mode
- A string composed of "r" and "w" indicating read or write access.bufferSize
- The dataBuffer.buffer size to be used. This should be substantially larger than 100 bytes and defaults to 32768 bytes in the other constructors.- Throws:
java.io.IOException
- if the file could not be opened
-
-
Method Detail
-
checkBuffer
private void checkBuffer(int needBytes) throws java.io.IOException
This should only be used when a small number of bytes is required (substantially smaller than bufferSize.- Parameters:
needBytes
- the number of bytes needed for the next read operation.- Throws:
java.io.IOException
- if the dataBuffer.buffer could not be filled
-
close
public void close() throws java.io.IOException
-
finalize
protected void finalize()
- Overrides:
finalize
in classjava.lang.Object
-
flush
public void flush() throws java.io.IOException
Description copied from interface:ArrayDataOutput
Flush the output buffer- Specified by:
flush
in interfaceArrayDataOutput
- Throws:
java.io.IOException
- if the flush of the underlying stream failed
-
getChannel
public java.nio.channels.FileChannel getChannel()
Get the channel associated with this file. Note that this returns the channel of the associated RandomAccessFile. Note that since the BufferedFile buffers the I/O's to the underlying file, the offset of the channel may be different than the offset of the BufferedFile. This is different than for a RandomAccessFile where the offsets are guaranteed to be the same.- Returns:
- the file channel
-
getFD
public java.io.FileDescriptor getFD() throws java.io.IOException
Get the file descriptor associated with this stream. Note that this returns the file descriptor of the associated RandomAccessFile.- Returns:
- the file descriptor
- Throws:
java.io.IOException
- if the descriptor could not be accessed.
-
getFilePointer
public long getFilePointer()
Get the current offset into the file.- Specified by:
getFilePointer
in interfaceRandomAccess
- Returns:
- the current position in the stream.
-
length
public long length() throws java.io.IOException
- Returns:
- the current length of the file.
- Throws:
java.io.IOException
- if the operation failed
-
mark
public void mark(int readlimit) throws java.io.IOException
Description copied from interface:ArrayDataInput
See the general contract of themark
method ofInputStream
.- Specified by:
mark
in interfaceArrayDataInput
- Parameters:
readlimit
- the maximum limit of bytes that can be read before the mark position becomes invalid.- Throws:
java.io.IOException
- if the operation failed- See Also:
BufferedInputStream.reset()
-
needBuffer
private void needBuffer(int need) throws java.io.IOException
- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException
- Returns:
- Read a byte.
- Throws:
java.io.IOException
- if the underlying read operation fails
-
read
public int read(boolean[] b) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read an array of boolean's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
b
- array of boolean's.- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(boolean[] b, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read a segment of an array of boolean's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
b
- array of boolean's.start
- start index in the arraylength
- number of array elements to read- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(byte[] buf) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read an array of byte's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
buf
- array of byte's.- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed- See Also:
DataInput.readFully(byte[])
-
read
public int read(byte[] buf, int offset, int len) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read a segment of an array of byte's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
buf
- array of byte's.offset
- start index in the arraylen
- number of array elements to read- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed- See Also:
ArrayDataInput.readFully(byte[], int, int)
-
read
public int read(char[] c) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read an array of char's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
c
- array of char's.- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(char[] c, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read a segment of an array of char's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
c
- array of char's.start
- start index in the arraylength
- number of array elements to read- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(double[] d) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read an array of double's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
d
- array of double's.- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(double[] d, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read a segment of an array of double's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
d
- array of double's.start
- start index in the arraylength
- number of array elements to read- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(float[] f) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read an array of float's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
f
- array of float's.- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(float[] f, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read a segment of an array of float's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
f
- array of float's.start
- start index in the arraylength
- number of array elements to read- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(int[] i) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read an array of int's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
i
- array of int's.- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(int[] i, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read a segment of an array of int's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
i
- array of int's.start
- start index in the arraylength
- number of array elements to read- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(long[] l) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read a segment of an array of long's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
l
- array of long's.- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(long[] l, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read a segment of an array of long's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
l
- array of long's.start
- start index in the arraylength
- number of array elements to read- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(short[] s) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read an array of short's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
s
- array of short's.- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
read
public int read(short[] s, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read a segment of an array of short's.- Specified by:
read
in interfaceArrayDataInput
- Parameters:
s
- array of short's.start
- start index in the arraylength
- number of array elements to read- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if one of the underlying read operations failed
-
readArray
@Deprecated public int readArray(java.lang.Object o) throws java.io.IOException
Deprecated.Description copied from interface:ArrayDataInput
Read a generic (possibly multidimensional) primitive array. An Object[] array is also a legal argument if each element of the array is a legal.The ArrayDataInput classes do not support String input since it is unclear how one would read in an Array of strings.
- Specified by:
readArray
in interfaceArrayDataInput
- Parameters:
o
- A [multidimensional] primitive (or Object) array.- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if the underlying stream failed
-
readBoolean
public boolean readBoolean() throws java.io.IOException
- Specified by:
readBoolean
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
readByte
public byte readByte() throws java.io.IOException
- Specified by:
readByte
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
readChar
public char readChar() throws java.io.IOException
- Specified by:
readChar
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
readDouble
public double readDouble() throws java.io.IOException
- Specified by:
readDouble
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
readFloat
public float readFloat() throws java.io.IOException
- Specified by:
readFloat
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
readFully
public void readFully(byte[] b) throws java.io.IOException
- Specified by:
readFully
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
readFully
public void readFully(byte[] b, int off, int len) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read a buffer and signal an EOF if the requested elements cannot be read. This differs from read(b,off,len) since that call will not signal and end of file unless no bytes can be read. However both of these routines will attempt to fill their buffers completely.- Specified by:
readFully
in interfaceArrayDataInput
- Specified by:
readFully
in interfacejava.io.DataInput
- Parameters:
b
- The input buffer.off
- The requested offset into the buffer.len
- The number of bytes requested.- Throws:
java.io.IOException
-
readInt
public int readInt() throws java.io.IOException
- Specified by:
readInt
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
readLArray
public long readLArray(java.lang.Object o) throws java.io.IOException
Description copied from interface:ArrayDataInput
Read an object. An EOF will be signaled if the object cannot be fully read. This version works even if the underlying data is more than 2 Gigabytes.- Specified by:
readLArray
in interfaceArrayDataInput
- Parameters:
o
- The object to be read. This object should be a primitive (possibly multi-dimensional) array.- Returns:
- number of bytes read.
- Throws:
java.io.IOException
- if the underlying stream failed
-
readLine
public java.lang.String readLine() throws java.io.IOException
Read a line of input.- Specified by:
readLine
in interfacejava.io.DataInput
- Returns:
- the next line.
- Throws:
java.io.IOException
-
readLong
public long readLong() throws java.io.IOException
- Specified by:
readLong
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
readShort
public short readShort() throws java.io.IOException
- Specified by:
readShort
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
readUnsignedByte
public int readUnsignedByte() throws java.io.IOException
- Specified by:
readUnsignedByte
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
readUnsignedShort
public int readUnsignedShort() throws java.io.IOException
- Specified by:
readUnsignedShort
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
readUTF
public java.lang.String readUTF() throws java.io.IOException
- Specified by:
readUTF
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
reset
public void reset() throws java.io.IOException
Description copied from interface:ArrayDataInput
See the general contract of thereset
method ofInputStream
.If
markpos
is-1
(no mark has been set or the mark has been invalidated), anIOException
is thrown. Otherwise,pos
is set equal tomarkpos
.- Specified by:
reset
in interfaceArrayDataInput
- Throws:
java.io.IOException
- if this stream has not been marked or, if the mark has been invalidated, or the stream has been closed by invoking itsFitsIO.close()
method, or an I/O error occurs.- See Also:
BufferedInputStream.mark(int)
-
seek
public void seek(long offsetFromStart) throws java.io.IOException
Description copied from interface:RandomAccess
Move to a specified location in the stream.- Specified by:
seek
in interfaceRandomAccess
- Parameters:
offsetFromStart
- set the offset messured from the start- Throws:
java.io.IOException
- if the operation fails
-
setLength
public void setLength(long newLength) throws java.io.IOException
Set the length of the file. This method calls the method of the same name in RandomAccessFile which is only available in JDK1.2 and greater. This method may be deleted for compilation with earlier versions.- Parameters:
newLength
- The number of bytes at which the file is set.- Throws:
java.io.IOException
- if the resizing of the underlying stream fails
-
skip
public long skip(long offset) throws java.io.IOException
Description copied from interface:ArrayDataInput
Skip the number of bytes. This differs from the skip method in that it will throw an EOF if a forward skip cannot be fully accomplished... (However that isn't supposed to happen with a random access file, so there is probably no operational difference).- Specified by:
skip
in interfaceArrayDataInput
- Parameters:
offset
- the number of bytes to skip- Returns:
- the number of bytes really skipped
- Throws:
java.io.IOException
- if the underlying stream failed
-
skipAllBytes
public void skipAllBytes(int toSkip) throws java.io.IOException
Description copied from interface:ArrayDataInput
Skip the number of bytes. This differs from the skip method in that it will throw an EOF if a forward skip cannot be fully accomplished... (However that isn't supposed to happen with a random access file, so there is probably no operational difference).- Specified by:
skipAllBytes
in interfaceArrayDataInput
- Parameters:
toSkip
- the number of bytes to skip- Throws:
java.io.IOException
- if the underlying stream failed
-
skipAllBytes
public void skipAllBytes(long toSkip) throws java.io.IOException
Description copied from interface:ArrayDataInput
Skip the number of bytes. This differs from the skip method in that it will throw an EOF if a forward skip cannot be fully accomplished... (However that isn't supposed to happen with a random access file, so there is probably no operational difference).- Specified by:
skipAllBytes
in interfaceArrayDataInput
- Parameters:
toSkip
- the number of bytes to skip- Throws:
java.io.IOException
- if the underlying stream failed
-
skipBytes
public int skipBytes(int n) throws java.io.IOException
- Specified by:
skipBytes
in interfacejava.io.DataInput
- Throws:
java.io.IOException
-
write
public void write(boolean[] b) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write an array of boolean's.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
b
- array of boolean's.- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(boolean[] b, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write a segment of an array of boolean's.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
b
- array of boolean's.start
- start index in the arraylength
- number of array elements to write- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(byte[] buf) throws java.io.IOException
- Specified by:
write
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
write
public void write(byte[] buf, int offset, int length) throws java.io.IOException
- Specified by:
write
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
write
public void write(char[] c) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write an array of char's.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
c
- array of char's.- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(char[] c, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write a segment of an array of char's.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
c
- array of char's.start
- start index in the arraylength
- number of array elements to write- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(double[] d) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write an array of double's.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
d
- array of double's.- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(double[] d, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write a segment of an array of double's.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
d
- array of double's.start
- start index in the arraylength
- number of array elements to write- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(float[] f) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write an array of float's.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
f
- array of float's.- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(float[] f, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write a segment of an array of float's.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
f
- array of float's.start
- start index in the arraylength
- number of array elements to write- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(int buf) throws java.io.IOException
- Specified by:
write
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
write
public void write(int[] i) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write an array of int's.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
i
- array of int's- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(int[] i, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write a segment of an array of int's.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
i
- array of int'sstart
- start index in the arraylength
- number of array elements to write- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(long[] l) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write an array of longs.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
l
- array of longs- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(long[] l, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write a segment of an array of longs.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
l
- array of longsstart
- start index in the arraylength
- number of array elements to write- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(short[] s) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write an array of shorts.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
s
- the value to write- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(short[] s, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write a segment of an array of shorts.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
s
- the value to writestart
- start index in the arraylength
- number of array elements to write- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(java.lang.String[] s) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write an array of Strings. Equivalent to calling writeBytes for the selected elements.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
s
- the array to write- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
write
public void write(java.lang.String[] s, int start, int length) throws java.io.IOException
Description copied from interface:ArrayDataOutput
Write a segment of an array of Strings. Equivalent to calling writeBytes for the selected elements.- Specified by:
write
in interfaceArrayDataOutput
- Parameters:
s
- the array to writestart
- start index in the arraylength
- number of array elements to write- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
writeArray
public void writeArray(java.lang.Object o) throws java.io.IOException
Description copied from interface:ArrayDataOutput
This routine provides efficient writing of arrays of any primitive type. The String class is also handled but it is an error to invoke this method with an object that is not an array of these types. If the array is multidimensional, then it calls itself recursively to write the entire array. Strings are written using the standard 1 byte format (i.e., as in writeBytes). If the array is an array of objects, then writePrimitiveArray will be called for each element of the array.- Specified by:
writeArray
in interfaceArrayDataOutput
- Parameters:
o
- The object to be written. It must be an array of a primitive type, Object, or String.- Throws:
java.io.IOException
- if one of the underlying write operations failed
-
writeBoolean
public void writeBoolean(boolean b) throws java.io.IOException
- Specified by:
writeBoolean
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeByte
public void writeByte(int b) throws java.io.IOException
- Specified by:
writeByte
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(java.lang.String s) throws java.io.IOException
- Specified by:
writeBytes
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeChar
public void writeChar(int c) throws java.io.IOException
- Specified by:
writeChar
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeChars
public void writeChars(java.lang.String s) throws java.io.IOException
- Specified by:
writeChars
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeDouble
public void writeDouble(double d) throws java.io.IOException
- Specified by:
writeDouble
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeFloat
public void writeFloat(float f) throws java.io.IOException
- Specified by:
writeFloat
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeInt
public void writeInt(int i) throws java.io.IOException
- Specified by:
writeInt
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeLong
public void writeLong(long l) throws java.io.IOException
- Specified by:
writeLong
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeShort
public void writeShort(int s) throws java.io.IOException
- Specified by:
writeShort
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeUTF
public void writeUTF(java.lang.String s) throws java.io.IOException
- Specified by:
writeUTF
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
-