@Override public void run(InputStream in) throws Exception { FileHelper.copy(in, out); } });
@Override public void run(InputStream in) throws Exception { FileHelper.copy(in, out); } });
@Override public void run(OutputStream out) throws Exception { FileHelper.copy(in, out); } });
@Override public void run(InputStream fileInput) throws Exception { FileHelper.copy(fileInput, zipOutput); } });
@Override public void run(OutputStream out) throws Exception { FileHelper.copy(in, out); } });
@Override public void run(OutputStream fileOutput) throws Exception { FileHelper.copy(zipInputStream, fileOutput); } };
@Override public void run(InputStream in) throws Exception { FileHelper.copy(in, out); } });
@Override public void run(OutputStream fileOutput) throws Exception { String jsonConf = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString( configuration); InputStream jsonConfStream = IOUtils.toInputStream(jsonConf); FileHelper.copy(jsonConfStream, fileOutput); } });
@Override public void run(OutputStream out) throws Exception { final InputStream in = file.getInputStream(); try { FileHelper.copy(in, out); } finally { FileHelper.safeClose(in); } } });
@Override public void run(OutputStream out) throws Exception { InputStream in = getClass().getResourceAsStream("default-conf.xml"); try { FileHelper.copy(in, out); } finally { FileHelper.safeClose(in); } }
@Override public void run(OutputStream out) throws Exception { final InputStream in = file.getInputStream(); try { FileHelper.copy(in, out); } finally { FileHelper.safeClose(in); } } };
public static byte[] readAsBytes(InputStream inputStream) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { copy(inputStream, baos); } finally { safeClose(inputStream); } return baos.toByteArray(); } }
public static byte[] readAsBytes(InputStream inputStream) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { copy(inputStream, baos); } finally { safeClose(inputStream); } return baos.toByteArray(); } }
private void fetchImage(HttpServletResponse response, String path) throws IOException { response.setContentType("image/png"); final InputStream in = getClass().getResourceAsStream(path); if (in == null) { logger.warn("Could not resolve image: {}", path); return; } try { FileHelper.copy(in, response.getOutputStream()); } catch (Exception e) { // errors here often happens when the client aborts because the // client Java already has a cached version of the file. if (logger.isInfoEnabled()) { logger.info("Failed to copy image file '" + path + "'", e); } } finally { FileHelper.safeClose(in); } }
public static void copy(File from, File to) throws IllegalStateException { assert from.exists(); final InputStream in = getInputStream(from); try { final OutputStream out = getOutputStream(to); try { copy(in, out); } finally { safeClose(out); } } finally { safeClose(in); } }
public static void copy(File from, File to) throws IllegalStateException { assert from.exists(); final InputStream in = getInputStream(from); try { final OutputStream out = getOutputStream(to); try { copy(in, out); } finally { safeClose(out); } } finally { safeClose(in); } }
public static void copy(Resource from, Resource to) throws IllegalStateException { assert from.isExists(); final InputStream in = from.read(); try { final OutputStream out = to.write(); try { copy(in, out); } finally { safeClose(out); } } finally { safeClose(in); } }
public static void copy(Resource from, Resource to) throws IllegalStateException { assert from.isExists(); final InputStream in = from.read(); try { final OutputStream out = to.write(); try { copy(in, out); } finally { safeClose(out); } } finally { safeClose(in); } }
/** * Writes the {@link Workbook} to a {@link Resource}. The {@link Workbook} will be closed as a result of this * operation! * * @param dataContext * @param wb */ public static void writeAndCloseWorkbook(ExcelDataContext dataContext, final Workbook wb) { // first write to a temp file to avoid that workbook source is the same // as the target (will cause read+write cyclic overflow) final Resource realResource = dataContext.getResource(); final Resource tempResource = new InMemoryResource(realResource.getQualifiedPath()); tempResource.write(out -> wb.write(out)); FileHelper.safeClose(wb); FileHelper.copy(tempResource, realResource); }
/** * Writes the {@link Workbook} to a {@link Resource}. The {@link Workbook} will be closed as a result of this * operation! * * @param dataContext * @param wb */ public static void writeAndCloseWorkbook(ExcelDataContext dataContext, final Workbook wb) { // first write to a temp file to avoid that workbook source is the same // as the target (will cause read+write cyclic overflow) final Resource realResource = dataContext.getResource(); final Resource tempResource = new InMemoryResource(realResource.getQualifiedPath()); tempResource.write(out -> wb.write(out)); FileHelper.safeClose(wb); FileHelper.copy(tempResource, realResource); }