MCPcopy Create free account
hub / github.com/ReadyTalk/avian / InputStreamChannel

Class InputStreamChannel

classpath/java/nio/channels/Channels.java:84–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected