@Test public void writesUtf8StringToOutputStream() throws Exception { MediaType mediaType = new MediaType("text", "plain"); ByteArrayOutputStream out = new ByteArrayOutputStream(); stringEntityProvider.writeTo(TEST_CONTENT, String.class, null, null, mediaType, new MultivaluedHashMap<>(), out); assertArrayEquals(TEST_CONTENT.getBytes("UTF-8"), out.toByteArray()); }
@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(); }
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(); } }
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(); }  }
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(); }  @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override String readFrom(Class<String> type,
                           Type genericType,
                           Annotation[] annotations,
                           MediaType mediaType,
                           MultivaluedMap<String, String> httpHeaders,
                           InputStream entityStream); @Override long getSize(String string, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(String string,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream); }
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(); }  @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override String readFrom(Class<String> type,
                           Type genericType,
                           Annotation[] annotations,
                           MediaType mediaType,
                           MultivaluedMap<String, String> httpHeaders,
                           InputStream entityStream); @Override long getSize(String string, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(String string,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream);  }