@Override public void provideResourceTo(Consumer<? super OutputStream> consumer) { try { OutputStream stream = new HUPReopeningFileOutputStream(file); try { BufferedOutputStream bufferedStream = new BufferedOutputStream(stream); try { consumer.accept(bufferedStream); } finally { try { bufferedStream.close(); } catch (Exception ex) { Logger.getLogger(LogFileStreamProvider.class.getName()).log(Level.SEVERE, null, ex); } } } finally { try { stream.close(); } catch (Exception ex) { Logger.getLogger(LogFileStreamProvider.class.getName()).log(Level.SEVERE, null, ex); } } } catch (IOException ex) { throw new RuntimeException(ex); } }
@Override public void provideResourceTo(Consumer<? super Handler> consumer) { Handler handler = Handlers.createFlushingHandler(stream); try { consumer.accept(handler); } finally { handler.close(); } }