記憶體流的使用

2021-08-02 10:39:37 字數 758 閱讀 1710

記憶體操作流:用於處理臨時儲存資訊的,程式結束,資料就從記憶體中消失。

名稱規則: 以位元組結尾的必須使用位元組輸出流結尾(in/out putstream)否則使用字元。

public

class bytearraystreamdemo

// 釋放資源

// 通過檢視原始碼我們知道這裡什麼都沒做,所以根本需要close()

// baos.close();

// public byte tobytearray()

byte bys = baos.tobytearray();

// 讀資料

// bytearrayinputstream(byte buf)

bytearrayinputstream bais = new bytearrayinputstream(bys);

int by = 0;

while ((by = bais.read()) != -1)

// bais.close();

}}

public

static

void

main(string args) throws ioexception

}

public

static

void

main(string args) throws ioexception

}

IO流 記憶體流

記憶體流 bytearrayinputstream bytearrayoutputstream chararrayinputstream charoutputstream stringreader stringwriter 目的 將資料臨時存放在陣列中 相當於記憶體中 tips 上面的writer ...

記憶體流的讀寫

using system using system.collections.generic using system.text using system.io namespace 記憶體流的讀寫 st.seek 0,seekorigin begin 把流移到最開始的位置 binaryreader b...

I O流之記憶體流

想進行i o操作但又不想產生檔案,即不用file,那麼我們就可以用記憶體流來實現。輸出outputstream 程式 outputstream 檔案 輸入inputstream 程式 inputstream 檔案 記憶體操作 輸出inputstream 程式 inputstream 記憶體 輸入ou...