@Test public void writesFileToOutputStream() throws Exception { File source = FileCollector.getInstance().createFile(); Files.write(testContent, source); ByteArrayOutputStream out = new ByteArrayOutputStream(); fileEntityProvider.writeTo(source, File.class, null, null, null, null, out); assertArrayEquals(testContent, out.toByteArray()); }
@Override public void writeTo(File file, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { try (InputStream in = new FileInputStream(file)) { ByteStreams.copy(in, entityStream); } }
FileEntityProvider implements EntityProvider<File> { @Override public void writeTo(File file, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { try (InputStream in = new FileInputStream(file)) { ByteStreams.copy(in, entityStream); } } }
FileEntityProvider implements EntityProvider<File> { @Override public void writeTo(File file, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { try (InputStream in = new FileInputStream(file)) { ByteStreams.copy(in, entityStream); } }  }
FileEntityProvider implements EntityProvider<File> { @Override public void writeTo(File file, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { try (InputStream in = new FileInputStream(file)) { ByteStreams.copy(in, entityStream); } }  @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override File readFrom(Class<File> type,
                         Type genericType,
                         Annotation[] annotations,
                         MediaType mediaType,
                         MultivaluedMap<String, String> httpHeaders,
                         InputStream entityStream); @Override long getSize(File file, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(File file,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream); }
FileEntityProvider implements EntityProvider<File> { @Override public void writeTo(File file, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { try (InputStream in = new FileInputStream(file)) { ByteStreams.copy(in, entityStream); } }  @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override File readFrom(Class<File> type,
                         Type genericType,
                         Annotation[] annotations,
                         MediaType mediaType,
                         MultivaluedMap<String, String> httpHeaders,
                         InputStream entityStream); @Override long getSize(File file, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(File file,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream);  }