MCPcopy Create free account
hub / github.com/davidgiven/luje / Writer

Class Writer

lib/java/io/Writer.java:37–253  ·  view source on GitHub ↗

The base class for all writers. A writer is a means of writing data to a target in a character-wise manner. Most output streams expect the #flush() method to be called before closing the stream, to ensure all data is actually written out. This abstract class does not provide a fully work

Source from the content-addressed store, hash-verified

35 * @see Reader
36 */
37public abstract class Writer implements Appendable, Closeable, Flushable {
38
39 static final String TOKEN_NULL = "null"; //$NON-NLS-1$
40
41 /**
42 * The object used to synchronize access to the writer.
43 */
44 protected Object lock;
45
46 /**
47 * Constructs a new {@code Writer} with {@code this} as the object used to
48 * synchronize critical sections.
49 */
50 protected Writer() {
51 super();
52 lock = this;
53 }
54
55 /**
56 * Constructs a new {@code Writer} with {@code lock} used to synchronize
57 * critical sections.
58 *
59 * @param lock
60 * the {@code Object} used to synchronize critical sections.
61 * @throws NullPointerException
62 * if {@code lock} is {@code null}.
63 */
64 protected Writer(Object lock) {
65 if (lock == null) {
66 throw new NullPointerException();
67 }
68 this.lock = lock;
69 }
70
71 /**
72 * Closes this writer. Implementations of this method should free any
73 * resources associated with the writer.
74 *
75 * @throws IOException
76 * if an error occurs while closing this writer.
77 */
78 public abstract void close() throws IOException;
79
80 /**
81 * Flushes this writer. Implementations of this method should ensure that
82 * all buffered characters are written to the target.
83 *
84 * @throws IOException
85 * if an error occurs while flushing this writer.
86 */
87 public abstract void flush() throws IOException;
88
89 /**
90 * Writes the entire character buffer {@code buf} to the target.
91 *
92 * @param buf
93 * the non-null array containing characters to write.
94 * @throws IOException

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected