code: public static void copyStream(OutputStream outs, InputStream ins) throws IOException
     {
        try
        {
           byte[] bytes = new byte[1024];
           int r = ins.read(bytes);
           while (r > 0)
           {
              outs.write(bytes, 0, r);
              r = ins.read(bytes);
           }
        }
        catch (IOException e)
        {
           throw e;
        }
        finally{
           ins.close();
        }
     }
docs: Copy the input stream to the output stream