Copies all characters between the Readable and Appendable objects. Does not close or flush either object. @param from the object to read from @param to the object to write to @return the number of characters copied @throws IOException if an I/O error occurs
(Readable from, Appendable to)
| 69 | */ |
| 70 | |
| 71 | @CanIgnoreReturnValue |
| 72 | public static long copy(Readable from, Appendable to) throws IOException { |
| 73 | checkNotNull(from); |
| 74 | checkNotNull(to); |
| 75 | CharBuffer buf = createBuffer(); |
| 76 | long total = 0; |
| 77 | while (from.read(buf) != -1) { |
| 78 | buf.flip(); |
| 79 | to.append(buf); |
| 80 | total += buf.remaining(); |
| 81 | buf.clear(); |
| 82 | } |
| 83 | return total; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Reads all characters from a {@link Readable} object into a {@link String}. Does not close the |
no test coverage detected