Exemple #1
0
        /// <summary>
        /// Creates a new NativePooledByteBuffer instance by reading
        /// in the entire contents of the byte array.
        /// </summary>
        /// <param name="bytes">
        /// The byte array to read from.
        /// </param>
        /// <returns>
        /// An instance of the NativePooledByteBuffer.
        /// </returns>
        public IPooledByteBuffer NewByteBuffer(byte[] bytes)
        {
            NativePooledByteBufferOutputStream outputStream =
                new NativePooledByteBufferOutputStream(_pool, bytes.Length);

            try
            {
                outputStream.Write(bytes, 0, bytes.Length);
                return(outputStream.ToByteBuffer());
            }
            catch (IOException)
            {
                throw;
            }
            finally
            {
                outputStream.Dispose();
            }
        }