Package com.google.api.client.util
Class IOUtils
java.lang.Object
com.google.api.client.util.IOUtils
Utilities for I/O streams.
- Since:
- 1.14
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic long
computeLength
(StreamingContent content) Computes and returns the byte content length for a streaming content by callingStreamingContent.writeTo(OutputStream)
on a fake output stream that only counts bytes written.static void
copy
(InputStream inputStream, OutputStream outputStream) Deprecated.static void
copy
(InputStream inputStream, OutputStream outputStream, boolean closeInputStream) Deprecated.useByteStreams.copy(InputStream, OutputStream)
static <S extends Serializable>
Sdeserialize
(byte[] bytes) Deserializes the given byte array into to a newly allocated object.static <S extends Serializable>
Sdeserialize
(InputStream inputStream) Deserializes the given input stream into to a newly allocated object, and close the input stream.static boolean
isSymbolicLink
(File file) Deprecated.use java.nio.file.Path#isSymbolicLinkstatic byte[]
Serializes the given object value to a newly allocated byte array.static void
serialize
(Object value, OutputStream outputStream) Serializes the given object value to an output stream, and close the output stream.
-
Constructor Details
-
IOUtils
public IOUtils()
-
-
Method Details
-
copy
@Deprecated public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException Deprecated.useByteStreams.copy(InputStream, OutputStream)
Writes the content provided by the given source input stream into the given destination output stream.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(); } }
- Parameters:
inputStream
- source input streamoutputStream
- destination output stream- Throws:
IOException
-
copy
@Deprecated public static void copy(InputStream inputStream, OutputStream outputStream, boolean closeInputStream) throws IOException Deprecated.useByteStreams.copy(InputStream, OutputStream)
Writes the content provided by the given source input stream into the given destination output stream, optionally closing the input stream.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(); } }
- Parameters:
inputStream
- source input streamoutputStream
- destination output streamcloseInputStream
- whether the input stream should be closed at the end of this method- Throws:
IOException
-
computeLength
Computes and returns the byte content length for a streaming content by callingStreamingContent.writeTo(OutputStream)
on a fake output stream that only counts bytes written.- Parameters:
content
- streaming content- Throws:
IOException
-
serialize
Serializes the given object value to a newly allocated byte array.- Parameters:
value
- object value to serialize- Throws:
IOException
- Since:
- 1.16
-
serialize
Serializes the given object value to an output stream, and close the output stream.- Parameters:
value
- object value to serializeoutputStream
- output stream to serialize into- Throws:
IOException
- Since:
- 1.16
-
deserialize
Deserializes the given byte array into to a newly allocated object.- Parameters:
bytes
- byte array to deserialize ornull
fornull
result- Returns:
- new allocated object or
null
fornull
input - Throws:
IOException
- Since:
- 1.16
-
deserialize
Deserializes the given input stream into to a newly allocated object, and close the input stream.- Parameters:
inputStream
- input stream to deserialize- Throws:
IOException
- Since:
- 1.16
-
isSymbolicLink
Deprecated.use java.nio.file.Path#isSymbolicLinkReturns whether the given file is a symbolic link.- Throws:
IOException
- Since:
- 1.16
-
ByteStreams.copy(InputStream, OutputStream)