| | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.CharBuffer; |
| | | import java.nio.channels.WritableByteChannel; |
| | | import java.nio.charset.Charset; |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Copies the entire contents of this byte string to the provided |
| | | * {@code WritableByteChannel}. |
| | | * |
| | | * @param channel |
| | | * The {@code WritableByteChannel} to copy to. |
| | | * @return The number of bytes written, possibly zero |
| | | * @throws IOException |
| | | * If some other I/O error occurs |
| | | * @see WritableByteChannel#write(java.nio.ByteBuffer) |
| | | */ |
| | | public int copyTo(WritableByteChannel channel) throws IOException { |
| | | return channel.write(ByteBuffer.wrap(buffer, 0, length)); |
| | | } |
| | | |
| | | /** |
| | | * Ensures that the specified number of additional bytes will fit in this |
| | | * byte string builder and resizes it if necessary. |
| | | * |