MCPcopy Create free account
hub / github.com/antlr/codebuff / writeFrom

Method writeFrom

corpus/java/training/guava/io/ByteSink.java:121–136  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

119 * this sink
120 */
121 @CanIgnoreReturnValue
122 public long writeFrom(InputStream input) throws IOException {
123 checkNotNull(input);
124
125 Closer closer = Closer.create();
126 try {
127 OutputStream out = closer.register(openStream());
128 long written = ByteStreams.copy(input, out);
129 out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
130 return written;
131 } catch (Throwable e) {
132 throw closer.rethrow(e);
133 } finally {
134 closer.close();
135 }
136 }
137
138 /**
139 * A char sink that encodes written characters with a charset and writes resulting bytes to this

Callers

nothing calls this directly

Calls 8

createMethod · 0.95
registerMethod · 0.95
openStreamMethod · 0.95
copyMethod · 0.95
rethrowMethod · 0.95
closeMethod · 0.95
checkNotNullMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected