/** * Returns a new {@link CharSink} for writing character data to the given file using the given * character set. The given {@code modes} control how the file is opened for writing. When no mode * is provided, the file will be truncated before writing. When the {@link FileWriteMode#APPEND * APPEND} mode is provided, writes will append to the end of the file without truncating it. * * @since 14.0 */ public static CharSink asCharSink(File file, Charset charset, FileWriteMode... modes) { return asByteSink(file, modes).asCharSink(charset); }
/** * Returns a view of the given {@code path} as a {@link CharSink} using the given {@code * charset}. * * <p>Any {@linkplain OpenOption open options} provided are used when opening streams to the file * and may affect the behavior of the returned sink and the streams it provides. See {@link * StandardOpenOption} for the standard options that may be provided. Providing no options is * equivalent to providing the {@link StandardOpenOption#CREATE CREATE}, {@link * StandardOpenOption#TRUNCATE_EXISTING TRUNCATE_EXISTING} and {@link StandardOpenOption#WRITE * WRITE} options. */ public static CharSink asCharSink(Path path, Charset charset, OpenOption... options) { return asByteSink(path, options).asCharSink(charset); }