public class IOUtils extends Object
| Constructor and Description |
|---|
IOUtils() |
| Modifier and Type | Method and Description |
|---|---|
static long |
computeLength(StreamingContent content)
Computes and returns the byte content length for a streaming content by calling
StreamingContent.writeTo(OutputStream) on a fake output stream that only counts bytes
written. |
static void |
copy(InputStream inputStream,
OutputStream outputStream)
Writes the content provided by the given source input stream into the given destination output
stream.
|
static void |
copy(InputStream inputStream,
OutputStream outputStream,
boolean closeInputStream)
Writes the content provided by the given source input stream into the given destination output
stream, optionally closing the input stream.
|
public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException
The input stream is guaranteed to be closed at the end of this method.
Sample use:
static void copy(InputStream inputStream, File file) throws IOException {
FileOutputStream out = new FileOutputStream(file);
try {
IOUtils.copy(inputStream, out);
} finally {
out.close();
}
}
inputStream - source input streamoutputStream - destination output streamIOExceptionpublic static void copy(InputStream inputStream, OutputStream outputStream, boolean closeInputStream) throws IOException
Sample use:
static void copy(InputStream inputStream, File file) throws IOException {
FileOutputStream out = new FileOutputStream(file);
try {
IOUtils.copy(inputStream, out, true);
} finally {
out.close();
}
}
inputStream - source input streamoutputStream - destination output streamcloseInputStream - whether the input stream should be closed at the end of this methodIOExceptionpublic static long computeLength(StreamingContent content) throws IOException
StreamingContent.writeTo(OutputStream) on a fake output stream that only counts bytes
written.content - streaming contentIOExceptionCopyright © 2011-2013 Google. All Rights Reserved.