public abstract class Writer extends Object implements Appendable, Closeable, Flushable
Writer
,
BufferedWriter
,
CharArrayWriter
,
FilterWriter
,
OutputStreamWriter
,
FileWriter
,
PipedWriter
,
PrintWriter
,
StringWriter
,
Reader
Modifier | Constructor and Description |
---|---|
protected |
Writer()
创建一个新的字符流的作者,其关键部分将同步在“作者”本身上。
|
protected |
Writer(Object lock)
创建一个新的字符流的作者,其关键部分将在给定的对象上同步。
|
Modifier and Type | Method and Description |
---|---|
Writer |
append(char c)
将指定的字符到这个作家。
|
Writer |
append(CharSequence csq)
将指定的字符序列,这个作家。
|
Writer |
append(CharSequence csq, int start, int end)
添加一个序列指定的字符序列,这个作家。
|
abstract void |
close()
关闭流,冲洗它。
|
abstract void |
flush()
冲流。
|
void |
write(char[] cbuf)
写一个字符数组。
|
abstract void |
write(char[] cbuf, int off, int len)
写入一个字符数组的一部分。
|
void |
write(int c)
写一个字符。
|
void |
write(String str)
写一个字符串。
|
void |
write(String str, int off, int len)
写入字符串的一部分。
|
protected Object lock
protected Writer()
protected Writer(Object lock)
lock
对象来同步
public void write(int c) throws IOException
打算支持高效的单字符输出的子类应重写此方法。
c
- int指定要写入的字符
IOException
如果I/O错误发生
public void write(char[] cbuf) throws IOException
cbuf
-要写入的字符数组
IOException
如果I/O错误发生
public abstract void write(char[] cbuf, int off, int len) throws IOException
cbuf
-字符数组
off
-开始写作的特点
len
数字写
IOException
如果I/O错误发生
public void write(String str) throws IOException
str
字符串被写入
IOException
如果I/O错误发生
public void write(String str, int off, int len) throws IOException
str
-一个字符串
off
偏移从开始写汉字
len
-字符数
IndexOutOfBoundsException
-如果
off是负的,或
len是负的,或
off+len阴性或大于给定的字符串的长度
IOException
如果I/O错误发生
public Writer append(CharSequence csq) throws IOException
这种形式的out.append(csq)方法调用的行为一样,调用
写出来。(CSQ。tostring())
根据字符序列的csq toString规范,整个序列可能不追加。例如,调用字符缓冲区的toString方法将返回一个序列的内容取决于缓冲区的位置和范围。
append
接口
Appendable
csq
-字符序列添加。如果
csq是
null,然后四个字
"null"附加到这个作家。
IOException
如果I/O错误发生
public Writer append(CharSequence csq, int start, int end) throws IOException
这种形式的out.append(csq, start, end)方法调用时,csq不null表现在完全相同的方式调用
写出来。(CSQ。子序列(开始、结束)。tostring())
append
接口
Appendable
csq
-字符序列的子序列将追加。如果
csq是
null,那么人物将追加好像
csq包含四个字符
"null"。
start
-子序列中的第一个字符的索引
end
-子序列中的最后一个字符后的字符的索引
IndexOutOfBoundsException
-如果
start或
end是负面的,
start大于
end,或
end大于
csq.length()
IOException
如果I/O错误发生
public Writer append(char c) throws IOException
这种形式的out.append(c)方法调用的行为一样,调用
外写(c)
append
接口
Appendable
c
- 16位字符追加
IOException
如果I/O错误发生
public abstract void flush() throws IOException
如果此流的预期目的地是底层操作系统提供的一个抽象,例如一个文件,然后刷新流只保证以前写入流的字节被传递给操作系统,它不保证它们实际上被写入到一个物理设备,如磁盘驱动器。
flush
接口
Flushable
IOException
如果I/O错误发生
public abstract void close() throws IOException
close
接口
Closeable
close
接口
AutoCloseable
IOException
如果I/O错误发生
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.