/** * Equivalent to calling {@code close(closeable, true)}, but with no * IOException in the signature. * @param closeable the {@code Closeable} object to be closed, or null, in * which case this method does nothing */ public static void closeQuietly(Closeable closeable) { try { close(closeable, true); } catch (IOException e) { logger.log(Level.SEVERE, "IOException should not have been thrown.", e); } } }
/** * Equivalent to calling {@code close(closeable, true)}, but with no * IOException in the signature. * @param closeable the {@code Closeable} object to be closed, or null, in * which case this method does nothing */ public static void closeQuietly(Closeable closeable) { try { close(closeable, true); } catch (IOException e) { logger.log(Level.SEVERE, "IOException should not have been thrown.", e); } } }
/** * Equivalent to calling {@code close(closeable, true)}, but with no * IOException in the signature. * @param closeable the {@code Closeable} object to be closed, or null, in * which case this method does nothing */ public static void closeQuietly(Closeable closeable) { try { close(closeable, true); } catch (IOException e) { logger.log(Level.SEVERE, "IOException should not have been thrown.", e); } } }
/** * Writes a character sequence (such as a string) to an appendable * object from the given supplier. * * @param from the character sequence to write * @param to the output supplier * @throws IOException if an I/O error occurs */ public static <W extends Appendable & Closeable> void write(CharSequence from, OutputSupplier<W> to) throws IOException { Preconditions.checkNotNull(from); boolean threw = true; W out = to.getOutput(); try { out.append(from); threw = false; } finally { Closeables.close(out, threw); } }
/** * Writes a character sequence (such as a string) to an appendable * object from the given supplier. * * @param from the character sequence to write * @param to the output supplier * @throws IOException if an I/O error occurs */ public static <W extends Appendable & Closeable> void write(CharSequence from, OutputSupplier<W> to) throws IOException { Preconditions.checkNotNull(from); boolean threw = true; W out = to.getOutput(); try { out.append(from); threw = false; } finally { Closeables.close(out, threw); } }
/** * Writes a character sequence (such as a string) to an appendable * object from the given supplier. * * @param from the character sequence to write * @param to the output supplier * @throws IOException if an I/O error occurs */ public static <W extends Appendable & Closeable> void write(CharSequence from, OutputSupplier<W> to) throws IOException { Preconditions.checkNotNull(from); boolean threw = true; W out = to.getOutput(); try { out.append(from); threw = false; } finally { Closeables.close(out, threw); } }
/** * Writes a character sequence (such as a string) to an appendable * object from the given supplier. * * @param from the character sequence to write * @param to the output supplier * @throws IOException if an I/O error occurs */ public static <W extends Appendable & Closeable> void write(CharSequence from, OutputSupplier<W> to) throws IOException { Preconditions.checkNotNull(from); boolean threw = true; W out = to.getOutput(); try { out.append(from); threw = false; } finally { Closeables.close(out, threw); } }
/** * Writes a character sequence (such as a string) to an appendable * object from the given supplier. * * @param from the character sequence to write * @param to the output supplier * @throws IOException if an I/O error occurs */ public static <W extends Appendable & Closeable> void write(CharSequence from, OutputSupplier<W> to) throws IOException { Preconditions.checkNotNull(from); boolean threw = true; W out = to.getOutput(); try { out.append(from); threw = false; } finally { Closeables.close(out, threw); } }
/** * Writes a character sequence (such as a string) to an appendable * object from the given supplier. * * @param from the character sequence to write * @param to the output supplier * @throws IOException if an I/O error occurs */ public static <W extends Appendable & Closeable> void write(CharSequence from, OutputSupplier<W> to) throws IOException { Preconditions.checkNotNull(from); boolean threw = true; W out = to.getOutput(); try { out.append(from); threw = false; } finally { Closeables.close(out, threw); } }
/** * Opens {@link Readable} and {@link Appendable} objects from the * given factories, copies all characters between the two, and closes * them. * * @param from the input factory * @param to the output factory * @return the number of characters copied * @throws IOException if an I/O error occurs */ public static <R extends Readable & Closeable, W extends Appendable & Closeable> long copy(InputSupplier<R> from, OutputSupplier<W> to) throws IOException { boolean threw = true; R in = from.getInput(); try { W out = to.getOutput(); try { long count = copy(in, out); threw = false; return count; } finally { Closeables.close(out, threw); } } finally { Closeables.close(in, threw); } }
/** * Opens {@link Readable} and {@link Appendable} objects from the * given factories, copies all characters between the two, and closes * them. * * @param from the input factory * @param to the output factory * @return the number of characters copied * @throws IOException if an I/O error occurs */ public static <R extends Readable & Closeable, W extends Appendable & Closeable> long copy(InputSupplier<R> from, OutputSupplier<W> to) throws IOException { boolean threw = true; R in = from.getInput(); try { W out = to.getOutput(); try { long count = copy(in, out); threw = false; return count; } finally { Closeables.close(out, threw); } } finally { Closeables.close(in, threw); } }
/** * Opens {@link Readable} and {@link Appendable} objects from the * given factories, copies all characters between the two, and closes * them. * * @param from the input factory * @param to the output factory * @return the number of characters copied * @throws IOException if an I/O error occurs */ public static <R extends Readable & Closeable, W extends Appendable & Closeable> long copy(InputSupplier<R> from, OutputSupplier<W> to) throws IOException { boolean threw = true; R in = from.getInput(); try { W out = to.getOutput(); try { long count = copy(in, out); threw = false; return count; } finally { Closeables.close(out, threw); } } finally { Closeables.close(in, threw); } }
/** * Opens {@link Readable} and {@link Appendable} objects from the * given factories, copies all characters between the two, and closes * them. * * @param from the input factory * @param to the output factory * @return the number of characters copied * @throws IOException if an I/O error occurs */ public static <R extends Readable & Closeable, W extends Appendable & Closeable> long copy(InputSupplier<R> from, OutputSupplier<W> to) throws IOException { boolean threw = true; R in = from.getInput(); try { W out = to.getOutput(); try { long count = copy(in, out); threw = false; return count; } finally { Closeables.close(out, threw); } } finally { Closeables.close(in, threw); } }
/** * Returns the characters from a {@link Readable} & {@link Closeable} object * supplied by a factory as a new {@link StringBuilder} instance. * * @param supplier the factory to read from * @throws IOException if an I/O error occurs */ private static <R extends Readable & Closeable> StringBuilder toStringBuilder( InputSupplier<R> supplier) throws IOException { boolean threw = true; R r = supplier.getInput(); try { StringBuilder result = toStringBuilder(r); threw = false; return result; } finally { Closeables.close(r, threw); } }
/** * Returns the characters from a {@link Readable} & {@link Closeable} object * supplied by a factory as a new {@link StringBuilder} instance. * * @param supplier the factory to read from * @throws IOException if an I/O error occurs */ private static <R extends Readable & Closeable> StringBuilder toStringBuilder( InputSupplier<R> supplier) throws IOException { boolean threw = true; R r = supplier.getInput(); try { StringBuilder result = toStringBuilder(r); threw = false; return result; } finally { Closeables.close(r, threw); } }
/** * Returns the characters from a {@link Readable} & {@link Closeable} object * supplied by a factory as a new {@link StringBuilder} instance. * * @param supplier the factory to read from * @throws IOException if an I/O error occurs */ private static <R extends Readable & Closeable> StringBuilder toStringBuilder( InputSupplier<R> supplier) throws IOException { boolean threw = true; R r = supplier.getInput(); try { StringBuilder result = toStringBuilder(r); threw = false; return result; } finally { Closeables.close(r, threw); } }
/** * Returns the characters from a {@link Readable} & {@link Closeable} object * supplied by a factory as a new {@link StringBuilder} instance. * * @param supplier the factory to read from * @throws IOException if an I/O error occurs */ private static <R extends Readable & Closeable> StringBuilder toStringBuilder( InputSupplier<R> supplier) throws IOException { boolean threw = true; R r = supplier.getInput(); try { StringBuilder result = toStringBuilder(r); threw = false; return result; } finally { Closeables.close(r, threw); } }
/** * Returns the characters from a {@link Readable} & {@link Closeable} object * supplied by a factory as a new {@link StringBuilder} instance. * * @param supplier the factory to read from * @throws IOException if an I/O error occurs */ private static <R extends Readable & Closeable> StringBuilder toStringBuilder( InputSupplier<R> supplier) throws IOException { boolean threw = true; R r = supplier.getInput(); try { StringBuilder result = toStringBuilder(r); threw = false; return result; } finally { Closeables.close(r, threw); } }
/** * Reads all of the lines from a {@link Readable} & {@link Closeable} object * supplied by a factory. The lines do not include line-termination * characters, but do include other leading and trailing whitespace. * * @param supplier the factory to read from * @return a mutable {@link List} containing all the lines * @throws IOException if an I/O error occurs */ public static <R extends Readable & Closeable> List<String> readLines( InputSupplier<R> supplier) throws IOException { boolean threw = true; R r = supplier.getInput(); try { List<String> result = readLines(r); threw = false; return result; } finally { Closeables.close(r, threw); } }
/** * Returns the characters from a {@link Readable} & {@link Closeable} object * supplied by a factory as a new {@link StringBuilder} instance. * * @param supplier the factory to read from * @throws IOException if an I/O error occurs */ private static <R extends Readable & Closeable> StringBuilder toStringBuilder( InputSupplier<R> supplier) throws IOException { boolean threw = true; R r = supplier.getInput(); try { StringBuilder result = toStringBuilder(r); threw = false; return result; } finally { Closeables.close(r, threw); } }