@Override public void close() { for (MachineProvisioningLocation<?> provisioner : provisioners) { if (provisioner instanceof Closeable) { Streams.closeQuietly((Closeable)provisioner); } } }
/** copies and closes both */ public static void copyClose(InputStream input, OutputStream output) { try { copy(input, output); } finally { closeQuietly(input); closeQuietly(output); } }
public static String readFullyAndClose(Reader is) { try { return readFully(is); } finally { Streams.closeQuietly(is); } }
public static String readFullyStringAndClose(InputStream is) { try { return readFullyString(is); } finally { Streams.closeQuietly(is); } }
public static InputStreamSupplier fromString(String input) { return new InputStreamSupplier(Streams.newInputStreamWithContents(input)); }
public StreamGobbler setPrefix(String prefix) { setLogPrefix(prefix); setPrintPrefix(prefix); return this; } public StreamGobbler setPrintPrefix(String prefix) {
/** creates a capturing context which sees the output to this stream, without interrupting the original target */ public OutputCapturingContext captureTee() { ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream toRestore = setThreadLocalPrintStream(new TeeOutputStream(getDelegate(), out)); return new OutputCapturingContext(this, out, toRestore); }
@Override public String toString() { return getOutputSoFar(); } public boolean isEmpty() {
@Override public void close() { running.set(false); interrupt(); }
public LoggingOutputStream build() { return new LoggingOutputStream(this); } }
/** creates a capturing context which eats the output to this stream, blocking the original target */ public OutputCapturingContext capture() { return new OutputCapturingContext(this); }
public DelegatingPrintStream() { super(new IllegalOutputStream()); }
public static InputStreamSupplier of(InputStream target) { return new InputStreamSupplier(target); }
public static Builder builder() { return new Builder(); }
public static byte[] readFullyAndClose(InputStream is) { try { return readFully(is); } finally { Streams.closeQuietly(is); } }
@Override public void close() { for (T machine : machines) { if (machine instanceof Closeable) Streams.closeQuietly((Closeable)machine); } }
@Override public void close() throws IOException { if (content != null) { Streams.closeQuietly(content); } }
/** Destroys the given location. */ public static void destroy(Location loc) { // TODO unmanage the location, if possible? if (loc instanceof Closeable) { Streams.closeQuietly((Closeable)loc); log.debug("closed "+loc); } }