public class FileDownloadRandomAccessFile extends Object implements FileDownloadOutputStream
RandomAccessFile.| Modifier and Type | Class and Description |
|---|---|
static class |
FileDownloadRandomAccessFile.Creator |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this output stream and releases any system resources associated with this stream.
|
void |
flushAndSync()
Flush all buffer to system and force all system buffers to synchronize with the underlying
device.
|
void |
seek(long offset)
Sets the file-pointer offset, measured from the beginning of this file, at which the next
read or write occurs.
|
void |
setLength(long totalBytes)
Sets the length of this file.
|
void |
write(byte[] b,
int off,
int len)
Writes
len bytes from the specified byte array
starting at offset off to this file. |
public void write(byte[] b,
int off,
int len)
throws IOException
FileDownloadOutputStreamlen bytes from the specified byte array
starting at offset off to this file.write in interface FileDownloadOutputStreamb - the data.off - the start offset in the data.len - the number of bytes to write.IOException - if an I/O error occurs.public void flushAndSync()
throws IOException
FileDownloadOutputStreamThis method must ensure all data whatever on buffers of VM or buffers of system for this output stream must persist on the physical media, otherwise the breakpoint will not be integrity.
flushAndSync in interface FileDownloadOutputStreamSyncFailedException - Thrown when the buffers cannot be flushed,
or because the system cannot guarantee that all the
buffers have been synchronized with physical media.IOExceptionOutputStream.flush(),
FileDescriptor.sync()public void close()
throws IOException
FileDownloadOutputStreamclose is that it closes the output stream. A closed stream
cannot perform output operations and cannot be reopened.
The close method of OutputStream does nothing.
close in interface FileDownloadOutputStreamIOException - if an I/O error occurs.public void seek(long offset)
throws IOException
FileDownloadOutputStreamseek in interface FileDownloadOutputStreamoffset - the offset position, measured in bytes from the
beginning of the file, at which to set the file
pointer.IOException - if offset is less than
0 or if an I/O error occurs.RandomAccessFile.seek(long),
FileChannel.position(long)public void setLength(long totalBytes)
throws IOException
FileDownloadOutputStream
If the present length of the file as returned by the length 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 length 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.
setLength in interface FileDownloadOutputStreamtotalBytes - The desired length of the fileIOException - If an I/O error occursRandomAccessFile.setLength(long)