|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
javax.crypto.CipherOutputStream
public class CipherOutputStream
CipherOutputStream 由一個 OutputStream 和一個 Cipher 組成,這樣 write() 方法才能在將資料寫出到底層 OutputStream 之前先對該資料進行處理。在由 CipherOutputStream 使用之前,密碼必須充分初始化。
例如,假設密碼初始化為加密,CipherOutputStream 將在寫出該加密資料之前,嘗試加密資料。
此類別嚴格遵守此語義,尤其是其祖先類別 java.io.OutputStream 和 java.io.FilterOutputStream 的失敗語義。此類別具有在其祖先類別中指定的所有方法,並且對所有的這些方法進行了覆寫。除此之外,此類別還對其祖先類別未拋出的所有異常進行捕獲。
對開發人員非常重要的一點是,不要使用未在此類別中定義或覆寫的方法(例如,後來加入到某個父級類別的新方法或建構子),因為那些方法的設計和實作有可能未考慮到對 CipherOutputStream 的安全影響。
OutputStream,
FilterOutputStream,
Cipher,
CipherInputStream| 欄位摘要 |
|---|
| 從類別 java.io.FilterOutputStream 繼承的欄位 |
|---|
out |
| 建構子摘要 | |
|---|---|
protected |
CipherOutputStream(OutputStream os)
從 OutputStream 建構 CipherOutputStream,不指定 Cipher。 |
|
CipherOutputStream(OutputStream os,
Cipher c)
從 OutputStream 和 Cipher 建構 CipherOutputStream。 |
| 方法摘要 | |
|---|---|
void |
close()
關閉此輸出串流並釋放任何與此串流關聯的系統資源。 |
void |
flush()
強制寫出已由封裝的密碼物件處理的任何快取記憶體輸出位元組來刷新此輸出串流。 |
void |
write(byte[] b)
從指定的位元組陣列中將 b.length 個位元組寫入此輸出串流。 |
void |
write(byte[] b,
int off,
int len)
將指定的位元組陣列中從 off 偏移量開始的 len 個位元組寫入此輸出串流。 |
void |
write(int b)
將指定的位元組寫入此輸出串流。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 建構子詳細資訊 |
|---|
public CipherOutputStream(OutputStream os,
Cipher c)
os - OutputStream 物件c - 已初始化的 Cipher 物件protected CipherOutputStream(OutputStream os)
os - OutputStream 物件| 方法詳細資訊 |
|---|
public void write(int b)
throws IOException
FilterOutputStream 中的 writeb - byte。
IOException - 如果發生 I/O 錯誤。
public void write(byte[] b)
throws IOException
b.length 個位元組寫入此輸出串流。
CipherOutputStream 的 write 方法調用帶三個參數的 write 方法,三個參數為 b、0 和 b.length。
FilterOutputStream 中的 writeb - 資料。
NullPointerException - 如果 b 為 null。
IOException - 如果發生 I/O 錯誤。write(byte[], int, int)
public void write(byte[] b,
int off,
int len)
throws IOException
off 偏移量開始的 len 個位元組寫入此輸出串流。
FilterOutputStream 中的 writeb - 資料。off - 資料中的初始偏移量。len - 要寫入的位元組數。
IOException - 如果發生 I/O 錯誤。FilterOutputStream.write(int)
public void flush()
throws IOException
由封裝的密碼快取記憶體並等待由其處理的任何位元組將不被寫出。例如,假設封裝的密碼為塊密碼,並且使用某個 write 方法寫入的總位元組數小於密碼的塊大小,將不寫出任何位元組。
Flushable 中的 flushFilterOutputStream 中的 flushIOException - 如果發生 I/O 錯誤。FilterOutputStream.out
public void close()
throws IOException
此方法調用封裝密碼物件的 doFinal 方法,它使得由該封裝密碼快取記憶體的任何位元組都被處理。通過調用此輸出串流的 flush 方法寫出結果。
此方法將封裝密碼物件重置為其初始狀態並調用底層輸出串流的 close 方法。
Closeable 中的 closeFilterOutputStream 中的 closeIOException - 如果發生 I/O 錯誤。FilterOutputStream.flush(),
FilterOutputStream.out
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。