|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface FileOperations
Elementary I/O operations.
| Field Summary | |
|---|---|
static int |
EOF
Constant returned by the read(byte[],int,int) method if the
end of the file has been reached. |
| Method Summary | |
|---|---|
void |
close()
Releases any system resources associated with an instance. |
long |
getFilePointer()
Returns the current offset in the file. |
long |
getLength()
Gets the length of the file. |
int |
read(byte[] buf,
int off,
int len)
Reads up to len bytes of data from the file into an array of
bytes. |
void |
read(OutputStream out)
Reads all data from the file to some OutputStream. |
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 len bytes from the specified byte array starting at
offset off to the file. |
void |
write(InputStream in)
Writes all data available from some InputStream. |
| Field Detail |
|---|
static final int EOF
read(byte[],int,int) method if the
end of the file has been reached.
| Method Detail |
|---|
void close()
throws IOException
IOException - if releasing system resources fails.
long getFilePointer()
throws IOException
IOException - if getting the current offset in the file fails.
long getLength()
throws IOException
IOException - if getting the length fails.
int read(byte[] buf,
int off,
int len)
throws IOException
len bytes of data from the file into an array of
bytes. An attempt is made to read as many as len bytes, but a
smaller number may be read.
buf - the buffer into which the data is read.off - the start offset of the data.len - the maximum number of bytes read.
EOF
if there is no more data because the end of the file has been reached.
NullPointerException - if buf is null.
IndexOutOfBoundsException - if either off or len
is negative or off + len is greater than the length of
buf.
IOException - if reading fails.
void read(OutputStream out)
throws IOException
OutputStream. The stream
will not get closed after all data has been written.
out - an output stream to stream to.
NullPointerException - if out is null.
IOException - if reading fails.
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 pos is negative.
IOException - if setting the file-pointer offset fails.
void setLength(long newLength)
throws IOException
If the present length of the file as returned by the
getLength() method is greater than the newLength argument
then the file will be truncated. In this case, if the file offset as
returned by the getFilePointer() method is greater than
newLength then after this method returns the offset will be equal
to newLength.
If the present length of the file as returned by the
getLength() method is smaller than the newLength 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 newLength is negative.
IOException - if setting the length fails.
void write(byte[] buf,
int off,
int len)
throws IOException
len bytes from the specified byte array starting at
offset off to the file.
buf - the data.off - the start offset in the data.len - the number of bytes to write.
IndexOutOfBoundsException - if either off or len
is negative or off + len is greater than the length of
buf.
IOException - if writing fails.
void write(InputStream in)
throws IOException
InputStream. The stream will
not get closed after all data has been read.
in - an input stream providing the data to be written.
NullPointerException - if in is null.
IOException - if writing fails.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||