|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Elementary I/O operations.
| Method Summary | |
long |
getFilePointer()
Returns the current offset in the file. |
long |
getLength()
Returns the length of the file. |
int |
read(byte[] buf,
int off,
int len)
Reads up to bytes of data from the file into an array of bytes. |
void |
read(OutputStream out)
Reads all data from the file to some . |
void |
setFilePointer(long pos)
Sets the file-pointer offset, measured from the beginning of the file, at which the next read or write occurs. |
void |
setLength(long newLength)
Sets the length of the file. |
void |
write(byte[] buf,
int off,
int len)
Writes bytes from the specified byte array starting at offset to the file. |
void |
write(InputStream in)
Writes all data available from some . |
| Method Detail |
public long getFilePointer()
throws IOException
IOException - if getting the current offset in the file fails.
public long getLength()
throws IOException
IOException - if getting the length fails.
public int read(byte[] buf,
int off,
int len)
throws IOException
buf - the buffer into which the data is read.off - the start offset of the data.len - the maximum number of bytes read.
NullPointerException - if is .
IndexOutOfBoundsException - if either or
is negative or is greater than the length of
.
IOException - if reading fails.
public void read(OutputStream out)
throws IOException
out - an output stream to stream to.
NullPointerException - if is .
IOException - if reading fails.
public void setFilePointer(long pos)
throws IOException
pos - the offset position, measured in bytes from the beginning of
the file, at which to set the file pointer.
IllegalArgumentException - if is negative.
IOException - if setting the file-pointer offset fails.
public void setLength(long newLength)
throws IOException
If the present length of the file as returned by the method is greater than the argument then the file will be truncated. In this case, if the file offset as returned by the method is greater than then after this method returns the offset will be equal to .
If the present length of the file as returned by the method is smaller than the argument then the file will be extended. In this case, the contents of the extended portion of the file are not defined.
newLength - The desired length of the file.
IllegalArgumentException - if is negative.
IOException - if setting the length fails.
public void write(byte[] buf,
int off,
int len)
throws IOException
buf - the data.off - the start offset in the data.len - the number of bytes to write.
IndexOutOfBoundsException - if either or
is negative or is greater than the length of
.
IOException - if writing fails.
public void write(InputStream in)
throws IOException
in - an input stream providing the data to be written.
NullPointerException - if is .
IOException - if writing fails.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||