/** * Copies all characters from a file to an appendable object, using the given character set. * * @param from the source file * @param charset the charset used to decode the input stream; see {@link StandardCharsets} for * helpful predefined constants * @param to the appendable object * @throws IOException if an I/O error occurs * @deprecated Prefer {@code asCharSource(from, charset).copyTo(to)}. This method is scheduled to * be removed in January 2019. */ @Deprecated public static void copy(File from, Charset charset, Appendable to) throws IOException { asCharSource(from, charset).copyTo(to); }
/** * Reads all characters from a file into a {@link String}, using the given character set. * * @param file the file to read from * @param charset the charset used to decode the input stream; see {@link StandardCharsets} for * helpful predefined constants * @return a string containing all the characters from the file * @throws IOException if an I/O error occurs * @deprecated Prefer {@code asCharSource(file, charset).read()}. This method is scheduled to be * removed in January 2019. */ @Deprecated public static String toString(File file, Charset charset) throws IOException { return asCharSource(file, charset).read(); }
/** * Reads the first line from a file. The line does not include line-termination characters, but * does include other leading and trailing whitespace. * * @param file the file to read from * @param charset the charset used to decode the input stream; see {@link StandardCharsets} for * helpful predefined constants * @return the first line, or null if the file is empty * @throws IOException if an I/O error occurs * @deprecated Prefer {@code asCharSource(file, charset).readFirstLine()}. This method is * scheduled to be removed in January 2019. */ @Deprecated public static String readFirstLine(File file, Charset charset) throws IOException { return asCharSource(file, charset).readFirstLine(); }
/** * Streams lines from a {@link File}, stopping when our callback returns false, or we have read * all of the lines. * * @param file the file to read from * @param charset the charset used to decode the input stream; see {@link StandardCharsets} for * helpful predefined constants * @param callback the {@link LineProcessor} to use to handle the lines * @return the output of processing the lines * @throws IOException if an I/O error occurs * @deprecated Prefer {@code asCharSource(file, charset).readLines(callback)}. This method is * scheduled to be removed in January 2019. */ @Deprecated @CanIgnoreReturnValue // some processors won't return a useful result public static <T> T readLines(File file, Charset charset, LineProcessor<T> callback) throws IOException { return asCharSource(file, charset).readLines(callback); }
return asCharSource(file, charset) .readLines( new LineProcessor<List<String>>() {