/** * Method description * * * @param input * @param output * * @throws IOException */ @Override public void process(File input, File output) throws IOException { Reader reader = null; Writer writer = null; try { reader = new FileReader(input); writer = new FileWriter(output); process(reader, writer); } finally { IOUtil.close(reader); IOUtil.close(writer); } }
/** * Method description * * * @param in * * @return * @since 1.8 * * @throws IOException */ public static String getContent(InputStream in) throws IOException { String content = null; ByteArrayOutputStream baos = null; try { baos = new ByteArrayOutputStream(); copy(in, baos); content = baos.toString(); } finally { close(baos); close(in); } return content; }
/** * Method description * * * @param input * @param output * * @throws IOException */ @Override public void process(File input, File output) throws IOException { Reader reader = null; Writer writer = null; try { reader = new FileReader(input); writer = new FileWriter(output); process(reader, writer); } finally { IOUtil.close(reader); IOUtil.close(writer); } }
/** * Method description * * * @param in * * @return * @since 1.8 * * @throws IOException */ public static String getContent(InputStream in) throws IOException { String content = null; ByteArrayOutputStream baos = null; try { baos = new ByteArrayOutputStream(); copy(in, baos); content = baos.toString(); } finally { close(baos); close(in); } return content; }
/** * Method description * * * @param sourcePropsFile * * @return */ private String getChecksumProperty(File sourcePropsFile) { Properties properties = new Properties(); FileInputStream input = null; try { input = new FileInputStream(sourcePropsFile); properties.load(input); } catch (IOException ex) { logger.error(ex.getMessage(), ex); } finally { IOUtil.close(input); } return properties.getProperty(PROPERTY_CHECKSUM); }
/** * Method description * * * @param sourcePropsFile * * @return */ private String getChecksumProperty(File sourcePropsFile) { Properties properties = new Properties(); FileInputStream input = null; try { input = new FileInputStream(sourcePropsFile); properties.load(input); } catch (IOException ex) { logger.error(ex.getMessage(), ex); } finally { IOUtil.close(input); } return properties.getProperty(PROPERTY_CHECKSUM); }
/** * Method description * * * @param input * @param outputFile * * @throws IOException */ private void extractFile(ZipInputStream input, File outputFile) throws IOException { FileOutputStream output = null; try { output = new FileOutputStream(outputFile); IOUtil.copy(input, output); } finally { IOUtil.close(output); } } }
/** * Method description * * * @param file * * @return * * @throws IOException */ public T read(File file) throws IOException { T result = null; InputStream input = null; try { input = new FileInputStream(file); result = read(input); } finally { IOUtil.close(input); } return result; } }
/** * Method description * * * @param input * @param outputFile * * @throws IOException */ private void extractFile(ZipInputStream input, File outputFile) throws IOException { FileOutputStream output = null; try { output = new FileOutputStream(outputFile); IOUtil.copy(input, output); } finally { IOUtil.close(output); } } }
/** * Skips to complete body of a request. * * * @param request http request * * @since 1.37 */ public static void drainBody(HttpServletRequest request) { if (isChunked(request) || (request.getContentLength() > 0)) { InputStream in = null; try { in = request.getInputStream(); while ((0 < in.skip(SKIP_SIZE)) || (0 <= in.read())) { // nothing } } catch (IOException e) {} finally { IOUtil.close(in); } } }
/** * Method description * * * @param file * * @return * * @throws IOException */ public T read(File file) throws IOException { T result = null; InputStream input = null; try { input = new FileInputStream(file); result = read(input); } finally { IOUtil.close(input); } return result; } }
/** * Method description * * * * @param request * @param response * @param message * */ public void sendError(HttpServletRequest request, HttpServletResponse response, String message) { setContentType(request, response); PrintWriter writer = null; try { writer = response.getWriter(); writer.println(message); } catch (IOException ex) { logger.error("could not write error message to client", ex); } finally { IOUtil.close(writer); } }