|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.api.client.http.AbstractInputStreamContent
public abstract class AbstractInputStreamContent
Serializes HTTP request content from an input stream into an output stream.
The type field is required. Subclasses should implement the HttpContent.getLength(),
getInputStream(), and HttpContent.retrySupported() for their specific type of input stream.
| Field Summary | |
|---|---|
String |
encoding
Content encoding (for example "gzip") or null for none. |
String |
type
Required content type. |
| Constructor Summary | |
|---|---|
AbstractInputStreamContent()
|
|
| Method Summary | |
|---|---|
static void |
copy(InputStream inputStream,
OutputStream outputStream)
Writes the content provided by the given source input stream into the given destination output stream. |
String |
getEncoding()
Returns the content encoding (for example "gzip") or null for none. |
protected abstract InputStream |
getInputStream()
Return an input stream for the specific implementation type of AbstractInputStreamContent. |
String |
getType()
Returns the content type or null for none. |
void |
writeTo(OutputStream out)
Writes the content to the given output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.google.api.client.http.HttpContent |
|---|
getLength, retrySupported |
| Field Detail |
|---|
public String type
public String encoding
"gzip") or null for none.
| Constructor Detail |
|---|
public AbstractInputStreamContent()
| Method Detail |
|---|
protected abstract InputStream getInputStream()
throws IOException
AbstractInputStreamContent. If the specific implementation will return true for
HttpContent.retrySupported() this should be a factory function which will create a new
InputStream from the source data whenever invoked.
IOException
public void writeTo(OutputStream out)
throws IOException
HttpContent
writeTo in interface HttpContentIOExceptionpublic String getEncoding()
HttpContent"gzip") or null for none.
getEncoding in interface HttpContentpublic String getType()
HttpContentnull for none.
getType in interface HttpContent
public static void copy(InputStream inputStream,
OutputStream outputStream)
throws IOException
The input stream is guaranteed to be closed at the end of the method.
Sample use:
static void downloadMedia(HttpResponse response, File file)
throws IOException {
FileOutputStream out = new FileOutputStream(file);
try {
AbstractInputStreamContent.copy(response.getContent(), out);
} finally {
out.close();
}
}
inputStream - source input streamoutputStream - destination output stream
IOException - I/O exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||