/** * Silently dump a file to the given destionation. All {@link IOException}s gets caught and * logged, but not re-thrown. * * @param out dump destination * @param file file to dump. * @param compressed if {@code true} the denoted file is assumed to be gzipped. * @return {@code true} on success (everything read and written). * @throws NullPointerException if a parameter is {@code null}. */ public static boolean dump(Writer out, File file, boolean compressed) { if (!file.exists()) { return false; } FileInputStream fis = null; GZIPInputStream gis = null; Reader in = null; try { if (compressed) { fis = new FileInputStream(file); gis = new GZIPInputStream(fis); in = new InputStreamReader(gis); } else { in = new FileReader(file); } dump(out, in); return true; } catch (IOException e) { OpenGrokLogger.getLogger() .log(Level.WARNING, "An error occured while piping file " + file + ": ", e); } finally { IOUtils.close(in); IOUtils.close(gis); IOUtils.close(fis); } return false; }