public static void copy(InputStream in, OutputStream out) throws IOException {
        byte[] buffer = new byte[1024];
        int len;
        while ((len = in.read(buffer)) != -1) {
            out.write(buffer, 0, len);
        }
    }
referer https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/IOUtils.java
cop/src/main/java/code/landgrey/copagent/utils/IOUtils.java