@Test public void readsContentOfEntityStreamAsString() throws Exception { MediaType mediaType = new MediaType("text", "plain", ImmutableMap.of("charset", "windows-1251")); byte[] data = TEST_CONTENT.getBytes("windows-1251"); String result = stringEntityProvider.readFrom(String.class, String.class, null, mediaType, null, new ByteArrayInputStream(data)); assertEquals(TEST_CONTENT, result); }
@Override public String readFrom(Class<String> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { return CharStreams.toString(new InputStreamReader(entityStream, getCharsetOrUtf8(mediaType))); }
StringEntityProvider implements EntityProvider<String> { @Override public String readFrom(Class<String> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { return CharStreams.toString(new InputStreamReader(entityStream, getCharsetOrUtf8(mediaType))); } }
StringEntityProvider implements EntityProvider<String> { @Override public String readFrom(Class<String> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { return CharStreams.toString(new InputStreamReader(entityStream, getCharsetOrUtf8(mediaType))); }  }
StringEntityProvider implements EntityProvider<String> { @Override public String readFrom(Class<String> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { return CharStreams.toString(new InputStreamReader(entityStream, getCharsetOrUtf8(mediaType))); }  @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 String readFrom(Class<String> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { return CharStreams.toString(new InputStreamReader(entityStream, getCharsetOrUtf8(mediaType))); }  @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);  }