/** * 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 * @deprecated Use {@link CharSource#readLines()} instead, but note that it returns an {@code * ImmutableList}. This method is scheduled for removal in Guava 18.0. */ @Deprecated public static <R extends Readable & Closeable> List<String> readLines(InputSupplier<R> supplier) throws IOException { Closer closer = Closer.create(); try { R r = closer.register(supplier.getInput()); return readLines(r); } catch (Throwable e) { throw closer.rethrow(e); } finally { closer.close(); } }
/** * Process the bytes of a supplied stream * * @param supplier the input stream factory * @param processor the object to which to pass the bytes of the stream * @return the result of the byte processor * @throws IOException if an I/O error occurs */ public static <T> T readBytes( InputSupplier<? extends InputStream> supplier, ByteProcessor<T> processor) throws IOException { checkNotNull(supplier); checkNotNull(processor); Closer closer = Closer.create(); try { InputStream in = closer.register(supplier.getInput()); return readBytes(in, processor); } catch (Throwable e) { throw closer.rethrow(e); } finally { closer.close(); } }
/** * Streams lines from a {@link Readable} and {@link Closeable} object supplied by a factory, * stopping when our callback returns false, or we have read all of the lines. * * @param supplier the factory to read from * @param callback the LineProcessor to use to handle the lines * @return the output of processing the lines * @throws IOException if an I/O error occurs * @deprecated Use {@link CharSource#readLines(LineProcessor)} instead. This method is scheduled * for removal in Guava 18.0. */ @Deprecated public static <R extends Readable & Closeable, T> T readLines( InputSupplier<R> supplier, LineProcessor<T> callback) throws IOException { checkNotNull(supplier); checkNotNull(callback); Closer closer = Closer.create(); try { R r = closer.register(supplier.getInput()); return readLines(r, callback); } catch (Throwable e) { throw closer.rethrow(e); } finally { closer.close(); } }
public static <R extends Readable, extends Closeable> List<String> readLines(InputSupplier<R> paramInputSupplier) throws IOException { Closer localCloser = Closer.create(); try { List localList = readLines((Readable)localCloser.register((Closeable)paramInputSupplier.getInput())); return localList; } catch (Throwable localThrowable) { throw localCloser.rethrow(localThrowable); } finally { localCloser.close(); } }
public static <R extends Readable, extends Closeable, T> T readLines(InputSupplier<R> paramInputSupplier, LineProcessor<T> paramLineProcessor) throws IOException { Preconditions.checkNotNull(paramInputSupplier); Preconditions.checkNotNull(paramLineProcessor); Closer localCloser = Closer.create(); try { Object localObject2 = readLines((Readable)localCloser.register((Closeable)paramInputSupplier.getInput()), paramLineProcessor); return localObject2; } catch (Throwable localThrowable) { throw localCloser.rethrow(localThrowable); } finally { localCloser.close(); } }