{{error}}
{{(quickSearchResults.length>10)?'10+':(quickSearchResults.length)}} {{(quickSearchResults.length==1)?'result':'results'}}
{{result.title}} {{result.timeStamp | mysql2ymd }}
I am sorry, no such article was written yet.
Simple stream copy function
Simple stream copy function
Simple function to copy a stream to another.
CopyStream.java
public static void copyStream(InputStream is, OutputStream os) throws IOException {
        try (
                ReadableByteChannel input = Channels.newChannel(is);
                WritableByteChannel output = Channels.newChannel(os)
        ) {
            final ByteBuffer buffer = ByteBuffer.allocateDirect(65536);
            while (input.read(buffer) != -1) {
                buffer.flip();
                output.write(buffer);
                buffer.compact();
            }
            buffer.flip();
            while (buffer.hasRemaining())
                output.write(buffer);
        }
    }