MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException, WebApplicationException {
// set content disposition. This will enable browsers to open excel
ContentDispositionHeader contentDispositionHeader =
ContentDispositionHeader.createContentDispositionHeader(MediaTypeUtils.CSV_TYPE);
contentDispositionHeader.setFileName("representation"); //$NON-NLS-1$
httpHeaders
.putSingle(CONTENT_DISPOSITION_HEADER, header.toString(contentDispositionHeader));
Charset charset = Charset.forName(ProviderUtils.getCharset(mediaType));
OutputStreamWriter writer = new OutputStreamWriter(entityStream, charset);