private static void copy(InputStream in, OutputStream out) throws IOException {
        byte[] buffer = new byte[4096];
        while (true) {
            int bytesRead = in.read(buffer);
            if (bytesRead < 0) {
                break;
            }
            out.write(buffer, 0, bytesRead);
        }
    }
Common code for copy routines.  By convention, the streams are
closed in the same method in which they were opened.  Thus,
this method does not close the streams when the copying is done.
@param in the input stream
@param out the output stream
@throws IOException if the copy failed
xmppserver/src/main/java/org/jivesoftware/util/WebManager.java