private void copyAndClose(InputStream inputStream, FileOutputStream outputStream) throws IOException {
        byte[] buffer = new byte[2048];
        int read;
        try {
            while((read=inputStream.read(buffer))>0) {
                outputStream.write(buffer, 0, read);
            }
        }
        finally {
            closeQuietly(inputStream);
            closeQuietly(outputStream);
        }
    }