2362N/A * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Utility methods for channels and streams. 0N/A * <p> This class defines static methods that support the interoperation of the 0N/A * stream classes of the <tt>{@link java.io}</tt> package with the channel 0N/A * classes of this package. </p> 0N/A * @author Mark Reinhold 0N/A * @author Mike McCloskey 0N/A * @author JSR-51 Expert Group 43N/A * Write all remaining bytes in buffer to the given channel. 43N/A * If the channel is selectable then it must be configured blocking. 43N/A * Write all remaining bytes in buffer to the given channel. 43N/A * @throws IllegalBlockingException 43N/A * If the channel is selectable and configured non-blocking. 0N/A // -- Byte streams from channels -- 0N/A * Constructs a stream that reads bytes from the given channel. 0N/A * <p> The <tt>read</tt> methods of the resulting stream will throw an 0N/A * {@link IllegalBlockingModeException} if invoked while the underlying 0N/A * channel is in non-blocking mode. The stream will not be buffered, and 0N/A * it will not support the {@link InputStream#mark mark} or {@link 0N/A * InputStream#reset reset} methods. The stream will be safe for access by 0N/A * multiple concurrent threads. Closing the stream will in turn cause the 0N/A * channel to be closed. </p> 0N/A * The channel from which bytes will be read 0N/A * @return A new input stream 0N/A * Constructs a stream that writes bytes to the given channel. 0N/A * <p> The <tt>write</tt> methods of the resulting stream will throw an 0N/A * {@link IllegalBlockingModeException} if invoked while the underlying 0N/A * channel is in non-blocking mode. The stream will not be buffered. The 0N/A * stream will be safe for access by multiple concurrent threads. Closing 0N/A * the stream will in turn cause the channel to be closed. </p> 0N/A * The channel to which bytes will be written 0N/A * @return A new output stream 0N/A private byte[]
bs =
null;
// Invoker's previous array 893N/A * Constructs a stream that reads bytes from the given channel. 893N/A * <p> The stream will not be buffered, and it will not support the {@link 893N/A * InputStream#mark mark} or {@link InputStream#reset reset} methods. The 893N/A * stream will be safe for access by multiple concurrent threads. Closing 893N/A * the stream will in turn cause the channel to be closed. </p> 893N/A * The channel from which bytes will be read 893N/A * @return A new input stream 893N/A private byte[]
bs =
null;
// Invoker's previous array 893N/A * Constructs a stream that writes bytes to the given channel. 893N/A * <p> The stream will not be buffered. The stream will be safe for access 893N/A * by multiple concurrent threads. Closing the stream will in turn cause 893N/A * the channel to be closed. </p> 893N/A * The channel to which bytes will be written 893N/A * @return A new output stream 893N/A private byte[]
bs =
null;
// Invoker's previous array 0N/A // -- Channels from streams -- 0N/A * Constructs a channel that reads bytes from the given stream. 0N/A * <p> The resulting channel will not be buffered; it will simply redirect 0N/A * its I/O operations to the given stream. Closing the channel will in 0N/A * turn cause the stream to be closed. </p> 0N/A * The stream from which bytes are to be read 0N/A * @return A new readable byte channel 0N/A private byte buf[] =
new byte[
0];
0N/A break;
// block at most once 0N/A * Constructs a channel that writes bytes to the given stream. 0N/A * <p> The resulting channel will not be buffered; it will simply redirect 0N/A * its I/O operations to the given stream. Closing the channel will in 0N/A * turn cause the stream to be closed. </p> 0N/A * The stream to which bytes are to be written 0N/A * @return A new writable byte channel 0N/A private byte buf[] =
new byte[
0];
0N/A // -- Character streams from channels -- 0N/A * Constructs a reader that decodes bytes from the given channel using the 0N/A * <p> The resulting stream will contain an internal input buffer of at 0N/A * least <tt>minBufferCap</tt> bytes. The stream's <tt>read</tt> methods 0N/A * will, as needed, fill the buffer by reading bytes from the underlying 0N/A * channel; if the channel is in non-blocking mode when bytes are to be 0N/A * read then an {@link IllegalBlockingModeException} will be thrown. The 0N/A * resulting stream will not otherwise be buffered, and it will not support 0N/A * the {@link Reader#mark mark} or {@link Reader#reset reset} methods. 0N/A * Closing the stream will in turn cause the channel to be closed. </p> 0N/A * The channel from which bytes will be read 0N/A * The charset decoder to be used 0N/A * @param minBufferCap 0N/A * The minimum capacity of the internal byte buffer, 0N/A * or <tt>-1</tt> if an implementation-dependent 0N/A * default capacity is to be used 0N/A * @return A new reader 0N/A * Constructs a reader that decodes bytes from the given channel according 0N/A * to the named charset. 0N/A * <p> An invocation of this method of the form 0N/A * Channels.newReader(ch, csname)</pre></blockquote> 0N/A * behaves in exactly the same way as the expression 0N/A * Channels.newReader(ch, 0N/A * Charset.forName(csName) 0N/A * -1);</pre></blockquote> 0N/A * The channel from which bytes will be read 0N/A * The name of the charset to be used 0N/A * @return A new reader 0N/A * @throws UnsupportedCharsetException 0N/A * If no support for the named charset is available 0N/A * in this instance of the Java virtual machine 0N/A * Constructs a writer that encodes characters using the given encoder and 0N/A * writes the resulting bytes to the given channel. 0N/A * <p> The resulting stream will contain an internal output buffer of at 0N/A * least <tt>minBufferCap</tt> bytes. The stream's <tt>write</tt> methods 0N/A * will, as needed, flush the buffer by writing bytes to the underlying 0N/A * channel; if the channel is in non-blocking mode when bytes are to be 0N/A * written then an {@link IllegalBlockingModeException} will be thrown. 0N/A * The resulting stream will not otherwise be buffered. Closing the stream 0N/A * will in turn cause the channel to be closed. </p> 0N/A * The channel to which bytes will be written 0N/A * The charset encoder to be used 0N/A * @param minBufferCap 0N/A * The minimum capacity of the internal byte buffer, 0N/A * or <tt>-1</tt> if an implementation-dependent 0N/A * default capacity is to be used 0N/A * @return A new writer 0N/A * Constructs a writer that encodes characters according to the named 0N/A * charset and writes the resulting bytes to the given channel. 0N/A * <p> An invocation of this method of the form 0N/A * Channels.newWriter(ch, csname)</pre></blockquote> 0N/A * behaves in exactly the same way as the expression 0N/A * Channels.newWriter(ch, 0N/A * Charset.forName(csName) 0N/A * -1);</pre></blockquote> 0N/A * The channel to which bytes will be written 0N/A * The name of the charset to be used 0N/A * @return A new writer 0N/A * @throws UnsupportedCharsetException 0N/A * If no support for the named charset is available 0N/A * in this instance of the Java virtual machine