Package com.google.common.io
Class CharSink
java.lang.Object
com.google.common.io.CharSink
- All Implemented Interfaces:
OutputSupplier<Writer>
@Deprecated(since="2022-12-01")
public abstract class CharSink
extends Object
implements OutputSupplier<Writer>
Deprecated.
The Google Guava Core Libraries are deprecated and will not be part of the AEM SDK after April 2023
A destination to which characters can be written, such as a text file. Unlike a
Writer
, a
CharSink
is not an open, stateful stream that can be written to and closed. Instead, it
is an immutable supplier of Writer
instances.
CharSink
provides two kinds of methods:
- Methods that return a writer: These methods should return a new, independent instance each time they are called. The caller is responsible for ensuring that the returned writer is closed.
- Convenience methods: These are implementations of common operations that are typically implemented by opening a writer using one of the methods in the first category, doing something and finally closing the writer that was opened.
Any ByteSink
may be viewed as a CharSink
with a specific character encoding using ByteSink.asCharSink(Charset)
. Characters written to the
resulting CharSink
will written to the ByteSink
as encoded bytes.
- Since:
- 14.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Writer
Deprecated.This method is only provided for temporary compatibility with theOutputSupplier
interface and should not be called directly.Deprecated.Opens a new bufferedWriter
for writing to this sink.abstract Writer
Deprecated.Opens a newWriter
for writing to this sink.void
write
(CharSequence charSequence) Deprecated.Writes the given character sequence to this sink.long
void
writeLines
(Iterable<? extends CharSequence> lines) Deprecated.Writes the given lines of text to this sink with each line (including the last) terminated with the operating system's default line separator.void
writeLines
(Iterable<? extends CharSequence> lines, String lineSeparator) Deprecated.Writes the given lines of text to this sink with each line (including the last) terminated with the given line separator.
-
Constructor Details
-
CharSink
public CharSink()Deprecated.
-
-
Method Details
-
openStream
Deprecated.Opens a newWriter
for writing to this sink. This method should return a new, independent writer each time it is called.The caller is responsible for ensuring that the returned writer is closed.
- Throws:
IOException
- if an I/O error occurs in the process of opening the writer
-
getOutput
Deprecated.This method is only provided for temporary compatibility with theOutputSupplier
interface and should not be called directly. UseopenStream()
instead.This method is a temporary method provided for easing migration from suppliers to sources and sinks.- Specified by:
getOutput
in interfaceOutputSupplier<Writer>
- Throws:
IOException
- Since:
- 15.0
-
openBufferedStream
Deprecated.Opens a new bufferedWriter
for writing to this sink. The returned stream is not required to be aBufferedWriter
in order to allow implementations to simply delegate toopenStream()
when the stream returned by that method does not benefit from additional buffering. This method should return a new, independent writer each time it is called.The caller is responsible for ensuring that the returned writer is closed.
- Throws:
IOException
- if an I/O error occurs in the process of opening the writer- Since:
- 15.0 (in 14.0 with return type
BufferedWriter
)
-
write
Deprecated.Writes the given character sequence to this sink.- Throws:
IOException
- if an I/O error in the process of writing to this sink
-
writeLines
Deprecated.Writes the given lines of text to this sink with each line (including the last) terminated with the operating system's default line separator. This method is equivalent towriteLines(lines, System.getProperty("line.separator"))
.- Throws:
IOException
- if an I/O error occurs in the process of writing to this sink
-
writeLines
public void writeLines(Iterable<? extends CharSequence> lines, String lineSeparator) throws IOException Deprecated.Writes the given lines of text to this sink with each line (including the last) terminated with the given line separator.- Throws:
IOException
- if an I/O error occurs in the process of writing to this sink
-
writeFrom
Deprecated.Writes all the text from the givenReadable
(such as aReader
) to this sink. Does not closereadable
if it isCloseable
.- Throws:
IOException
- if an I/O error occurs in the process of reading fromreadable
or writing to this sink
-