| 82 | } |
| 83 | |
| 84 | private static class InputStreamChannel implements ReadableByteChannel { |
| 85 | private InputStream stream; |
| 86 | |
| 87 | public InputStreamChannel(InputStream stream) { |
| 88 | this.stream = stream; |
| 89 | } |
| 90 | |
| 91 | public void close() throws IOException { |
| 92 | if (stream != null) { |
| 93 | stream.close(); |
| 94 | stream = null; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | public boolean isOpen() { |
| 99 | return stream != null; |
| 100 | } |
| 101 | |
| 102 | public int read(ByteBuffer b) throws IOException { |
| 103 | int c = stream.read |
| 104 | (b.array(), b.arrayOffset() + b.position(), b.remaining()); |
| 105 | |
| 106 | if (c > 0) { |
| 107 | b.position(b.position() + c); |
| 108 | } |
| 109 | |
| 110 | return c; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | private static class OutputStreamChannel implements WritableByteChannel { |
| 115 | private OutputStream stream; |
nothing calls this directly
no outgoing calls
no test coverage detected