Copies the contents of this byte source to the given OutputStream. Does not close output. @return the number of bytes copied @throws IOException if an I/O error occurs in the process of reading from this source or writing to output
(OutputStream output)
| 253 | */ |
| 254 | |
| 255 | @CanIgnoreReturnValue |
| 256 | public long copyTo(OutputStream output) throws IOException { |
| 257 | checkNotNull(output); |
| 258 | Closer closer = Closer.create(); |
| 259 | try { |
| 260 | InputStream in = closer.register(openStream()); |
| 261 | return ByteStreams.copy(in, output); |
| 262 | } catch (Throwable e) { |
| 263 | throw closer.rethrow(e); |
| 264 | } finally { |
| 265 | closer.close(); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * Copies the contents of this byte source to the given {@code ByteSink}. |
no test coverage detected