Ejemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void close() throws java.io.IOException
        public override void Close()
        {
            _buffer.clear();

            if (_channel != null)
            {
                _channel.close();
            }
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void fastCopy(java.io.InputStream paramInputStream, java.io.OutputStream paramOutputStream) throws java.io.IOException
        public static void fastCopy(Stream paramInputStream, Stream paramOutputStream)
        {
            ReadableByteChannel readableByteChannel = Channels.newChannel(paramInputStream);
            WritableByteChannel writableByteChannel = Channels.newChannel(paramOutputStream);
            ByteBuffer          byteBuffer          = ByteBuffer.allocateDirect(16384);

            while (readableByteChannel.read(byteBuffer) != -1)
            {
                byteBuffer.flip();
                writableByteChannel.write(byteBuffer);
                byteBuffer.compact();
            }
            byteBuffer.flip();
            while (byteBuffer.hasRemaining())
            {
                writableByteChannel.write(byteBuffer);
            }
            readableByteChannel.close();
            writableByteChannel.close();
        }