21天精通java基礎之Day15IO流(二)

2021-07-28 21:10:11 字數 1502 閱讀 2014

day15io流(二):

使用filereader、filewriter可以實現文字檔案的複製。

例項:

@test

public void testfilereaderwriter1()

} catch (exception e) finally catch (ioexception e)

}if(fr != null) catch (ioexception e)

}}

bufferedinputstream,bufferedoutputstream

例項:

@test

public void testbuffered1()

} catch (filenotfoundexception e) catch (ioexception e) finally catch (ioexception e)

}if(bis != null) catch (ioexception e)

} }

}

緩衝流例項:

bufferedreader、bufferedwriter

@test

public void testbuffered2()

} catch (filenotfoundexception e) catch (ioexception e) finally catch (ioexception e)

}if(br != null) catch (ioexception e)

}

} }

轉換流:inputstreamreader outputstreamwriter

編碼:字串---》位元組陣列

解碼:位元組陣列---》字串

標準的輸入輸出流:

標準的輸入流:system.in

標準的輸出流:system.out

題目:從鍵盤輸入字串,要求將讀取到的整行字串轉換成大寫輸出,然後繼續進行輸入操作,直到當輸入「e」,或者輸入「exit」時,退出程式。

@test

public void test()

string upper = str.touppercase();

system.out.println(upper);

}} catch (ioexception e) finally catch (ioexception e)

}}

資料流:

用來處理基本的資料型別、string、位元組陣列的資料:datainputstream dataoutputstream.

randomaccessfile:支援隨機訪問

1.既可以充當乙個輸入流,又可以充當乙個輸出流。

2.支援從檔案的開頭讀取、寫入。

3.支援從任意位置的讀取、寫入(插入)。

21天精通java基礎之Day13Map介面

map介面 hashmap 主要實現類。linkedhashmap 使用鍊錶維護新增進map中的順序。故遍歷map時,是按新增的順序遍歷的。treemap 按照新增進map中元素的key的指定屬性進行排序。要求,key必須是同乙個類的物件 hashtable 古老的實現類,執行緒安全,不建議使用。p...

21天精通java基礎之Day14泛型

day14 泛型 不使用泛型的危害 1.不使用泛型,任何object及其子類的物件都可以新增進來。2.強轉為int型時,可能報classcastexception的異常。泛型的使用 1.在集合中使用 test public void test public void test2 2.自定義泛型類 泛...

21天精通位元幣

最近我身邊接觸位元幣的人越來越多了,我也加了兩個群,群友都是標準的 黨 趨勢黨,簡單的說很多都是追漲殺跌。從每一次 的突變處找到殺入的時機,漲到止盈點就離場。運氣好,就如其所願,運氣不好,就立馬割肉。而我作為一 市上堅定的價值投資者,從來不去做短期的漲跌 只做長期的價值判斷。對於有價值的資產,我都會...