/** * Reads all characters from a {@link Readable} object into a new * {@link StringBuilder} instance. Does not close the {@code Readable}. * * @param r the object to read from * @return a {@link StringBuilder} containing all the characters * @throws IOException if an I/O error occurs */ private static StringBuilder toStringBuilder(Readable r) throws IOException { StringBuilder sb = new StringBuilder(); copy(r, sb); return sb; }
/** Varargs form of {@link #join(Iterable)}. */ public static InputSupplier<Reader> join( InputSupplier<? extends Reader>... suppliers) { return join(Arrays.asList(suppliers)); }
/** * Returns the characters from a {@link Readable} & {@link Closeable} object * supplied by a factory as a {@link String}. * * @param supplier the factory to read from * @return a string containing all the characters * @throws IOException if an I/O error occurs */ public static <R extends Readable & Closeable> String toString( InputSupplier<R> supplier) throws IOException { return toStringBuilder(supplier).toString(); }
CharStreams.toString( new InputStreamReader( httpConn.getInputStream(), Charsets.ISO_8859_1));
/** * 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); } }
CharStreams.toString( new InputStreamReader( httpConn.getInputStream(), Charsets.ISO_8859_1));
/** * 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); } }
/** * Reads all characters from a {@link Readable} object into a {@link String}. * Does not close the {@code Readable}. * * @param r the object to read from * @return a string containing all the characters * @throws IOException if an I/O error occurs */ public static String toString(Readable r) throws IOException { return toStringBuilder(r).toString(); }
/** * Reads all characters from a {@link Readable} object into a new * {@link StringBuilder} instance. Does not close the {@code Readable}. * * @param r the object to read from * @return a {@link StringBuilder} containing all the characters * @throws IOException if an I/O error occurs */ private static StringBuilder toStringBuilder(Readable r) throws IOException { StringBuilder sb = new StringBuilder(); copy(r, sb); return sb; }
CharStreams.toString( new InputStreamReader( httpConn.getInputStream(), Charsets.ISO_8859_1));
/** Varargs form of {@link #join(Iterable)}. */ public static InputSupplier<Reader> join( InputSupplier<? extends Reader>... suppliers) { return join(Arrays.asList(suppliers)); }
/** * 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 {@link String}. * * @param supplier the factory to read from * @return a string containing all the characters * @throws IOException if an I/O error occurs */ public static <R extends Readable & Closeable> String toString( InputSupplier<R> supplier) throws IOException { return toStringBuilder(supplier).toString(); }
/** * Reads all characters from a {@link Readable} object into a new * {@link StringBuilder} instance. Does not close the {@code Readable}. * * @param r the object to read from * @return a {@link StringBuilder} containing all the characters * @throws IOException if an I/O error occurs */ private static StringBuilder toStringBuilder(Readable r) throws IOException { StringBuilder sb = new StringBuilder(); copy(r, sb); return sb; }
CharStreams.toString( new InputStreamReader( httpConn.getInputStream(), Charsets.ISO_8859_1));
/** Varargs form of {@link #join(Iterable)}. */ public static InputSupplier<Reader> join( InputSupplier<? extends Reader>... suppliers) { return join(Arrays.asList(suppliers)); }
/** * Reads all characters from a {@link Readable} object into a {@link String}. * Does not close the {@code Readable}. * * @param r the object to read from * @return a string containing all the characters * @throws IOException if an I/O error occurs */ public static String toString(Readable r) throws IOException { return toStringBuilder(r).toString(); }
/** * Opens a {@link Readable} object from the supplier, copies all characters * to the {@link Appendable} object, and closes the input. Does not close * or flush the output. * * @param from the input factory * @param to the object to write to * @return the number of characters copied * @throws IOException if an I/O error occurs */ public static <R extends Readable & Closeable> long copy(InputSupplier<R> from, Appendable to) throws IOException { boolean threw = true; R in = from.getInput(); try { long count = copy(in, to); threw = false; return count; } finally { Closeables.close(in, threw); } }
CharStreams.toString( new InputStreamReader( httpConn.getInputStream(), Charsets.ISO_8859_1));
/** * Reads all characters from a {@link Readable} object into a {@link String}. * Does not close the {@code Readable}. * * @param r the object to read from * @return a string containing all the characters * @throws IOException if an I/O error occurs */ public static String toString(Readable r) throws IOException { return toStringBuilder(r).toString(); }