public interface FileDownloadOutputStream
FileDownloadRandomAccessFile| 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 newLength)
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. |
void write(byte[] b,
int off,
int len)
throws java.io.IOException
len bytes from the specified byte array
starting at offset off to this file.b - the data.off - the start offset in the data.len - the number of bytes to write.java.io.IOException - if an I/O error occurs.void flushAndSync()
throws java.io.IOException
This 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.
java.io.SyncFailedException - Thrown when the buffers cannot be flushed,
or because the system cannot guarantee that all the
buffers have been synchronized with physical media.java.io.IOExceptionOutputStream.flush(),
FileDescriptor.sync()void close()
throws java.io.IOException
close 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.
java.io.IOException - if an I/O error occurs.void seek(long offset)
throws java.io.IOException,
java.lang.IllegalAccessException
offset - the offset position, measured in bytes from the
beginning of the file, at which to set the file
pointer.java.io.IOException - if offset is less than
0 or if an I/O error occurs.java.lang.IllegalAccessException - if in this output stream doesn't support this function.
You can return false in
FileDownloadHelper.OutputStreamCreator#supportSeek()
let the internal mechanism can predict this situation, and
handle it smoothly.RandomAccessFile.seek(long),
FileChannel.position(long)void setLength(long newLength)
throws java.io.IOException,
java.lang.IllegalAccessException
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.
newLength - The desired length of the filejava.io.IOException - If an I/O error occursjava.lang.IllegalAccessException - If in this output stream doesn't support this function.RandomAccessFile.setLength(long)