Writes all the bytes from the given InputStream to this sink. Does not close input. @return the number of bytes written @throws IOException if an I/O occurs in the process of reading from input or writing to this sink
(InputStream input)
| 128 | */ |
| 129 | |
| 130 | @CanIgnoreReturnValue |
| 131 | public long writeFrom(InputStream input) throws IOException { |
| 132 | checkNotNull(input); |
| 133 | Closer closer = Closer.create(); |
| 134 | try { |
| 135 | OutputStream out = closer.register(openStream()); |
| 136 | long written = ByteStreams.copy(input, out); |
| 137 | out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330 |
| 138 | return written; |
| 139 | } catch (Throwable e) { |
| 140 | throw closer.rethrow(e); |
| 141 | } finally { |
| 142 | closer.close(); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * A char sink that encodes written characters with a charset and writes resulting bytes to this |
nothing calls this directly
no test coverage detected