位元組流和字元流的轉換

2021-09-25 16:26:03 字數 518 閱讀 9046

outputstreamwriter:將位元組輸出流轉換為字元輸出流

inputstreamreader:將位元組輸入流轉換為字元輸入流

我們先看下這兩個類的繼承關係和構造方法

public

class

outputstreamwriter

extends

writer

public

outputstreamwriter

(outputstream out)

public

class

inputstreamreader

extends

reader

public

inputstreamreader

(inputstream in)

觀察位元組流和字元流的轉換

public

class

catsreamtranst

}}

字元流和位元組流

字元流和位元組流及其相關流的繼承關係 常用的方法 1.close 關閉流並釋放與之相關聯的任何系統資源 2.int read 讀取乙個字元並返回,沒有讀到返回 1 3.int read char cbuf 將字元讀入陣列,並返回讀取字元的個數,沒有讀到返回 1 4.int read char cbu...

字元流和位元組流

字元流和位元組流 位元組流兩個基類 inputstream outputstream 字元流兩個基類 reader writer 先學習一下字元流特點。既然io流是用於運算元據的。那麼資料的最常見體現形式是 檔案。那麼先以操作檔案為主來顯示。需求 在硬碟上,建立乙個檔案並寫入一些文字資料。找到乙個專...

位元組流 字元流

fileoutputstream 構造 構造方法摘要 fileoutputstream file file 建立輸出流,不是以續寫方式關聯 fileoutputstream string name 建立輸出流,不是以續寫方式關聯 作用 1.建立乙個輸出流物件 2.如果你關聯的檔案,或者檔案的字串不存...