MCPcopy
hub / github.com/google/guava / copy

Method copy

guava/src/com/google/common/io/ByteStreams.java:108–123  ·  guava/src/com/google/common/io/ByteStreams.java::ByteStreams.copy

Copies all bytes from the input stream to the output stream. Does not close or flush either stream. <p><b>Java 9 users and later:</b> this method should be treated as deprecated; use the equivalent {@link InputStream#transferTo} method instead. @param from the input stream to read from @param to t

(InputStream from, OutputStream to)

Source from the content-addressed store, hash-verified

106 * @throws IOException if an I/O error occurs
107 */
108 @CanIgnoreReturnValue
109 public static long copy(InputStream from, OutputStream to) throws IOException {
110 checkNotNull(from);
111 checkNotNull(to);
112 byte[] buf = createBuffer();
113 long total = 0;
114 while (true) {
115 int r = from.read(buf);
116 if (r == -1) {
117 break;
118 }
119 to.write(buf, 0, r);
120 total += r;
121 }
122 return total;
123 }
124
125 /**
126 * Copies all bytes from the readable channel to the writable channel. Does not close or flush

Callers 7

writeFromMethod · 0.95
copyToMethod · 0.95
testOpenStreamMethod · 0.95
testCopyChannelMethod · 0.95
testCopyFileChannelMethod · 0.95

Calls 10

createBufferMethod · 0.95
flipMethod · 0.95
clearMethod · 0.95
writeMethod · 0.65
sizeMethod · 0.65
checkNotNullMethod · 0.45
readMethod · 0.45
positionMethod · 0.45
wrapMethod · 0.45
hasRemainingMethod · 0.45

Tested by

no test coverage detected