@Override public long transferTo(OutputStream out) throws IOException { return super.transferTo(out); }
/** * Write response body to file */ public Response<Path> writeTo(Path path) { return handle((charset, ri) -> { try (var out = Files.newOutputStream(path)) { ri.body().transferTo(out); } return null; }); }
/** * Write response body to OutputStream. OutputStream will not be closed. */ public Response<Void> writeTo(OutputStream out) { return handle((charset, ri) -> { ri.body().transferTo(out); return null; }); }
/** * @param input * @return the content of the input stream as a byte[] * @throws IOException */ public static byte[] toByteArray(InputStream input) throws IOException { FastByteArrayOutputStream output = new FastByteArrayOutputStream(); input.transferTo(output); return output.toByteArray(); }
/** * Copies the content of the specified binary file to the specified output stream. * * @param file the regular file to copy inside the ZIP file. * @param bundle the ZIP file where to copy the given regular file. */ private static void copy(final File file, final ZipOutputStream bundle) throws IOException { final String name = file.getName(); final ZipEntry entry = new ZipEntry(name); if (name.endsWith(".png")) { final long size = file.length(); entry.setMethod(ZipOutputStream.STORED); entry.setSize(size); entry.setCompressedSize(size); entry.setCrc(getCRC32(file)); } bundle.putNextEntry(entry); try (InputStream in = new FileInputStream(file)) { in.transferTo(bundle); } bundle.closeEntry(); }
if (!name.startsWith(NATIVE_DIRECTORY)) { out.putNextEntry(new ZipEntry(name)); eis.transferTo(out); // Copy the entry verbatim. out.closeEntry(); } else if (!entry.isDirectory()) {
inStream.transferTo(out); out.closeEntry();
try (final InputStream in = MinSite.class.getResourceAsStream("minisite.css")) { in.transferTo(out);