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)
| 238 | * writing to {@code output} |
| 239 | */ |
| 240 | @CanIgnoreReturnValue |
| 241 | public long copyTo(OutputStream output) throws IOException { |
| 242 | checkNotNull(output); |
| 243 | |
| 244 | Closer closer = Closer.create(); |
| 245 | try { |
| 246 | InputStream in = closer.register(openStream()); |
| 247 | return ByteStreams.copy(in, output); |
| 248 | } catch (Throwable e) { |
| 249 | throw closer.rethrow(e); |
| 250 | } finally { |
| 251 | closer.close(); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * Copies the contents of this byte source to the given {@code ByteSink}. |
no test coverage detected