鴻蒙OS FilterWriter

2022-10-19 17:53 更新

FilterWriter

java.lang.Object

|---java.io.Writer

|---|---java.io.FilterWriter

public abstract class FilterWriter
extends Writer

用于編寫過濾字符流的抽象類。 抽象類 FilterWriter 本身提供了將所有請(qǐng)求傳遞給包含的流的默認(rèn)方法。 FilterWriter 的子類應(yīng)該覆蓋其中的一些方法,并且還可以提供額外的方法和字段。

Since:

JDK1.1

字段摘要

修飾符和類型 字段 描述
protected Writer out 底層字符輸出流。
從類 java.io.Writer 繼承的字段
lock

構(gòu)造函數(shù)摘要

修飾符 構(gòu)造函數(shù) 描述
protected FilterWriter(Writer out) 創(chuàng)建一個(gè)新的過濾 writer。

方法總結(jié)

修飾符和類型 方法 描述
void close() 關(guān)閉流,首先刷新它。
void flush() 沖洗流。
void write(char[] cbuf, int off, int len) 寫入字符數(shù)組的一部分。
void write(int c) 寫入單個(gè)字符。
void write(String str, int off, int len) 寫入字符串的一部分。
從類 java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
從類 java.io.Writer 繼承的方法
append, append, append, write, write

字段詳細(xì)信息

out

protected Writer out

底層字符輸出流。

構(gòu)造函數(shù)詳細(xì)信息

FilterWriter

protected FilterWriter(Writer out)

創(chuàng)建一個(gè)新的過濾 writer。

參數(shù):

參數(shù)名稱 參數(shù)描述
out 提供底層流的 Writer 對(duì)象。

Throws:

Throw名稱 Throw描述
NullPointerException 如果 out 為空

方法詳情

write

public void write(int c) throws IOException

寫入單個(gè)字符。

覆蓋:

在 Writer 類中寫

參數(shù):

參數(shù)名稱 參數(shù)描述
c int 指定要寫入的字符

Throws:

Throw名稱 Throw描述
IOException 如果發(fā)生 I/O 錯(cuò)誤

write

public void write(char[] cbuf, int off, int len) throws IOException

寫入字符數(shù)組的一部分。

指定者:

在 Writer 類中寫

參數(shù):

參數(shù)名稱 參數(shù)描述
cbuf 要寫入的字符緩沖區(qū)
off 開始讀取字符的偏移量
len 要寫入的字符數(shù)

Throws:

Throw名稱 Throw描述
IOException 如果發(fā)生 I/O 錯(cuò)誤

write

public void write(String str, int off, int len) throws IOException

寫入字符串的一部分。

覆蓋:

在 Writer 類中寫

參數(shù):

參數(shù)名稱 參數(shù)描述
str 要寫入的字符串
off 開始讀取字符的偏移量
len 要寫入的字符數(shù)

Throws:

Throw名稱 Throw描述
IOException 如果發(fā)生 I/O 錯(cuò)誤

flush

public void flush() throws IOException

沖洗流。

指定者:

在接口 Flushable 中刷新

指定者:

在 Writer 類中刷新

Throws:

Throw名稱 Throw描述
IOException 如果發(fā)生 I/O 錯(cuò)誤

close

public void close() throws IOException

從班級(jí)復(fù)制的描述:Writer

關(guān)閉流,首先刷新它。 一旦流被關(guān)閉,進(jìn)一步的 write() 或 flush() 調(diào)用將導(dǎo)致拋出 IOException。 關(guān)閉以前關(guān)閉的流沒有效果。

指定者:

在接口 AutoCloseable 中關(guān)閉

指定者:

在接口Closeable中關(guān)閉

指定者:

close in class Writer

Throws:

Throw名稱 Throw描述
IOException 如果發(fā)生 I/O 錯(cuò)誤
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)