@@ -0,0 +1,1972 @@
+/* Copyright (c) 2010, Avian Contributors%0A%0A   Permission to use, copy, modify, and/or distribute this software%0A   for any purpose with or without fee is hereby granted, provided%0A   that the above copyright notice and this permission notice appear%0A   in all copies.%0A%0A   There is NO WARRANTY for this software.  See license.txt for%0A   details. */%0A%0Apackage java.nio.channels;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream;%0Aimport java.nio.ByteBuffer;%0A%0Apublic class Channels %7B%0A  public static InputStream newInputStream(ReadableByteChannel channel) %7B%0A    return new MyInputStream(channel);%0A  %7D%0A%0A  public static OutputStream newOutputStream(WritableByteChannel channel) %7B%0A    return new MyOutputStream(channel);%0A  %7D%0A%0A  private static class MyInputStream extends InputStream %7B%0A    private final ReadableByteChannel channel;%0A%0A    public MyInputStream(ReadableByteChannel channel) %7B%0A      this.channel = channel;%0A    %7D%0A%0A    public int read() throws IOException %7B%0A      byte%5B%5D buffer = new byte%5B1%5D;%0A      int r = read(buffer);%0A      if (r == -1) %7B%0A        return -1;%0A      %7D else %7B%0A        return buffer%5B0%5D & 0xFF;%0A      %7D%0A    %7D%0A%0A    public int read(byte%5B%5D buffer, int offset, int length) throws IOException %7B%0A      return channel.read(ByteBuffer.wrap(buffer, offset, length));%0A    %7D%0A%0A    public void close() throws IOException %7B%0A      channel.close();%0A    %7D%0A  %7D%0A%0A  private static class MyOutputStream extends OutputStream %7B%0A    private final WritableByteChannel channel;%0A%0A    public MyOutputStream(WritableByteChannel channel) %7B%0A      this.channel = channel;%0A    %7D%0A%0A    public void write(int v) throws IOException %7B%0A      byte%5B%5D buffer = new byte%5B%5D %7B (byte) (v & 0xFF) %7D;%0A      write(buffer);%0A    %7D%0A%0A    public void write(byte%5B%5D buffer, int offset, int length)%0A      throws IOException%0A    %7B%0A      channel.write(ByteBuffer.wrap(buffer, offset, length));%0A    %7D%0A%0A    public void close() throws IOException %7B%0A      channel.close();%0A    %7D%0A  %7D%0A%7D%0A

add java.nio.channels.Channels implementation