@Override
    @SuppressWarnings("resource")
    public void writeTo(Metadata metadata, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream) throws IOException, WebApplicationException {

        if (metadata.names().length != 1) {
            throw new WebApplicationException("Metadata object must only have one entry!");
        }
        Writer writer = new OutputStreamWriter(entityStream, UTF_8);

        for (String name : metadata.names()) {
            writer.write(metadata.get(name));
        }

        // Don't close, just flush the stream
        writer.flush();
    }
Returns simple text string for a particular metadata value.
This assumes that the metadata object only has one key;
if there is more than one key or no keys, this will throw a webapp exception.
<p/>
This will choose the first value returned for the one key.
tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/writer/TextMessageBodyWriter.java