2362N/A * Copyright (c) 2000, 2005, 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 * A channel that can write bytes. 0N/A * <p> Only one write operation upon a writable channel may be in progress at 0N/A * any given time. If one thread initiates a write operation upon a channel 0N/A * then any other thread that attempts to initiate another write operation will 0N/A * block until the first operation is complete. Whether or not other kinds of 0N/A * I/O operations may proceed concurrently with a write operation depends upon 0N/A * the type of the channel. </p> 0N/A * @author Mark Reinhold 0N/A * @author JSR-51 Expert Group 0N/A * Writes a sequence of bytes to this channel from the given buffer. 0N/A * <p> An attempt is made to write up to <i>r</i> bytes to the channel, 0N/A * where <i>r</i> is the number of bytes remaining in the buffer, that is, 0N/A * <tt>src.remaining()</tt>, at the moment this method is invoked. 0N/A * <p> Suppose that a byte sequence of length <i>n</i> is written, where 0N/A * <tt>0</tt> <tt><=</tt> <i>n</i> <tt><=</tt> <i>r</i>. 0N/A * This byte sequence will be transferred from the buffer starting at index 0N/A * <i>p</i>, where <i>p</i> is the buffer's position at the moment this 0N/A * method is invoked; the index of the last byte written will be 0N/A * <i>p</i> <tt>+</tt> <i>n</i> <tt>-</tt> <tt>1</tt>. 0N/A * Upon return the buffer's position will be equal to 0N/A * <i>p</i> <tt>+</tt> <i>n</i>; its limit will not have changed. 0N/A * <p> Unless otherwise specified, a write operation will return only after 0N/A * writing all of the <i>r</i> requested bytes. Some types of channels, 0N/A * depending upon their state, may write only some of the bytes or possibly 0N/A * none at all. A socket channel in non-blocking mode, for example, cannot 0N/A * write any more bytes than are free in the socket's output buffer. 0N/A * <p> This method may be invoked at any time. If another thread has 0N/A * already initiated a write operation upon this channel, however, then an 0N/A * invocation of this method will block until the first operation is 0N/A * The buffer from which bytes are to be retrieved 0N/A * @return The number of bytes written, possibly zero 0N/A * @throws NonWritableChannelException 0N/A * If this channel was not opened for writing 0N/A * @throws ClosedChannelException 0N/A * If this channel is closed 0N/A * @throws AsynchronousCloseException 0N/A * If another thread closes this channel 0N/A * while the write operation is in progress 0N/A * @throws ClosedByInterruptException 0N/A * If another thread interrupts the current thread 0N/A * while the write operation is in progress, thereby 0N/A * closing the channel and setting the current thread's 0N/A * @throws IOException 0N/A * If some other I/O error occurs