class StringEntityProvider implements EntityProvider<String> {

    @Override
    public void writeTo(String string,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream) throws IOException {
        Writer writer = new OutputStreamWriter(entityStream, getCharsetOrUtf8(mediaType));
        writer.write(string);
        writer.flush();
    }

}