private class HTTPClientSource.WrappedFileOutputStream
extends java.io.FileOutputStream
FileOutputStream to
automatically upload the data written to it, upon a close()
operation.| Modifier and Type | Field and Description |
|---|---|
private java.io.File |
m_file
Reference to the File being written itself.
|
private org.apache.avalon.framework.logger.Logger |
m_logger
Reference to a
Logger. |
| Constructor and Description |
|---|
HTTPClientSource.WrappedFileOutputStream(java.io.File file,
org.apache.avalon.framework.logger.Logger logger)
Constructor, creates a new
HTTPClientSource.WrappedFileOutputStream
instance. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canCancel()
Method to test whether this stream can be closed.
|
void |
cancel()
Cancels this stream.
|
void |
close()
Closes the stream, and uploads the file written to the
server.
|
private boolean |
successfulUpload(int response)
According to RFC2616 (HTTP 1.1) valid responses for a HTTP PUT
are 201 (Created), 200 (OK), and 204 (No Content).
|
private void |
upload()
Helper method to attempt uploading of the local data file
to the remove server via a HTTP PUT.
|
private java.io.File m_file
private final org.apache.avalon.framework.logger.Logger m_logger
Logger.public HTTPClientSource.WrappedFileOutputStream(java.io.File file,
org.apache.avalon.framework.logger.Logger logger)
throws java.io.IOException
HTTPClientSource.WrappedFileOutputStream
instance.file - File to write to.logger - Logger reference.java.io.IOException - if an error occurspublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.FileOutputStreamjava.io.IOException - if an error occurspublic boolean canCancel()
true if possible, false otherwise.public void cancel()
throws java.io.IOException
java.io.IOException - if stream is already closedprivate void upload()
throws java.io.IOException
java.io.IOException - if an error occursprivate boolean successfulUpload(int response)
response - response code from the HTTP PUT