freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內容

[計算機軟件及應用]java語言程序設計_基礎篇_中文ppt_第十九章(編輯修改稿)

2024-11-12 23:12 本頁面
 

【文章內容簡介】 : I n p u t S t r e am) Liang, Introduction to Java Programming, Eighth Edition, (c) 2021 Pearson Education, Inc. All rights reserved. 0132130807 16 DataOutputStream DataOutputStream類擴展 FilterOutputStream類并實現 DataOutput接口。 j a va . i o . D a t a O u t p u t + w ri t eB o o l e a n ( b : Bo o l e a n ) : vo i d + w ri t eB yt e( v: i n t ) : vo i d + w ri t eB yt es( s: S t ri n g ) : v o i d + w ri t eC h a r( c: ch a r) : v o i d + w ri t eC h a rs ( s: S t r i n g ) : v o i d + w ri t eF l o a t ( v: f l o a t ) : v o i d + w ri t eD o u b l e( v: f l o a t ) : v o i d + w ri t eI n t ( v: i n t ) : v o i d + w ri t eL o n g ( v: l o n g ) : v o i d + w ri t e S h o rt( v: s h o r t ) : v o i d + w ri t eU T F( s: S t r i n g ) : v o i d 向輸出流寫入一個布爾值 向輸出流寫入參數 v 的 8 個低階位 向輸出流寫入一個字符串的低字節(jié)字符 向輸出流寫入一個字符( 由 2 個字節(jié)構成 ) 向輸出流寫入字符串 s 中的每個字符,依序兩個字節(jié)為一個字符 向輸出流寫入一個 f l o at 值 向輸出流寫入一個 d o u b l e 值 向輸出 流寫入一個 i n t 值 向輸出流寫入一個 l o n g 值 向輸出流寫入一個 s h o r t 值 寫入一個 U TF 格式的字符串 s O u t p u t S t re a m F i l t e r O u t p u t S t r e am D at aO u t p u t S t r e am + D at aO u t p u t S t r e am( o u t : O u t p u t S t r e am) Liang, Introduction to Java Programming, Eighth Edition, (c) 2021 Pearson Education, Inc. All rights reserved. 0132130807 17 二進制 I/O中的字符和字符串 一個統一碼由兩個字節(jié)構成。方法 writeChar(char c)將字符 c的統一碼寫入輸出流。方法 writeChars(String s) 將字符串 s中的每個字符的統一碼都寫到輸出流中。 為什么使用 UTF8? 什么是 UTF8? UTF8是一種編碼方案,它允許系統和統一碼及 ASCII碼一起高效操作。大多數操作系統使用 ASCII碼, Java使用統一碼。ASCII碼字符集是統一碼字符集的子集。由于許多應用程序只需要 ASCII碼字符集,所以將 8位的 ASCII碼轉化為 16位的統一碼是很浪費的。 UTF8是一個可選的方案,它使用 1字節(jié)、 2字節(jié)或 3字節(jié)來存儲字符。 ASCII值(小于 0x7F)就使用一字節(jié)編碼。統一碼小于 0x7FF就使用兩字節(jié)如果字符編碼。其它統一碼值使用三個字節(jié)編碼。 Liang, Introduction to Java Programming, Eighth Edition, (c) 2021 Pearson Education, Inc. All rights reserved. 0132130807 18 使用 DataInputStream/DataOutputStream 數據流用于對已經存在的輸入 /輸出流進行包裝,以便在原始流中過濾數據。可以使用下面的構造方法來創(chuàng)建它們: public DataInputStream(InputStream instream) public DataOutputStream(OutputStream outstream) 下面給出的語句會創(chuàng)建數據流。第一條語句為文件 輸入流;而第二條語句為文件 : DataInputStream infile = new DataInputStream(new FileInputStream())。 DataOutputStream outfile = new DataOutputStream(new FileOutputStream())。 TestDataStream Run Liang, Introduction to Java Programming, Eighth Edition, (c) 2021 Pearson Education, Inc. All rights reserved. 0132130807 19 檢測文件末尾 提示:如果到達 InputStream的末尾之后還繼續(xù)從中讀取數據,就會發(fā)生 EOFException異常。如何檢測一個文件的末尾呢?可以使用 ()方法來檢測。當 () == 0 表明文件到達末尾。 順序和格式 警告:必須按存儲的順序和格式讀取文件中的數據。例如:學生的姓名是用 writeUTF方法以 UTF8格式寫入的,所以,讀取時必須使用 readUTF方法。 Liang, Introduction to Java Programming, Eighth Edition, (c) 2021 Pearson Education, Inc. All rights reserved. 0132130807 20 BufferedInputStream/ BufferedOutputStream 使用緩沖來提高 輸入 /輸出的速度 I n p u t S t r e a m O u t p u t S t re a m O b j e ct O b j e ct O u t p u t S t r e am F i l t e r O u t p u t S t r e am F i l e O u t p u t S t r e am B u f f e r e d I n p u t S t r e am D at aI n p u t S t r e am B u f f e r e d O u t p u t S t r e am D at aO u t p u t S t r e am P r i n t S t r e am O b j e ct I n p u t S t r e am F i l t e r I n p u t S t r e am F i l eI n p u t S t r e am BufferedInputStream類和 BufferedOutputStream類都沒有包含新方法。 BufferedInputStream類和 BufferedOutputStream中的所有方法都是從InputStream類和 OutputStream類繼承而來的。 Liang, Introduction to Java Programming, Eighth Edition, (c) 2021 Pearson Education, Inc. All rights reserved. 0132130807 21 構造 BufferedInputStream流和BufferedOutputStream流 // Create a BufferedInputStream public BufferedInputStream(InputStream in) public BufferedInputStream(InputStream in, int bufferSize) // Create a BufferedOutputStream public BufferedOutputStream(OutputStream out) public BufferedOutputStream(OutputStreamr out, int bufferSize) Liang, Introduction to Java Programming, Eighth Edition, (c) 2021 Pearson Education, Inc. All rights reserved. 0132130807 22 實例學習:復制文件 該實例開發(fā)一個復制文件的程序。用戶需要提供一個源文件與一個目標文件作為命令行參數,所使用的命令如下: java Copy source target 該程序將源文件復制到目標文件,然后顯示這個文件中的字節(jié)數。如果源文件不存在,就會告知用戶找不到這個文件。如果目標文件已經存在,就告知用戶目標文件存在。 Copy Run Liang, Introduction to Java Programming, Eighth Edition, (c) 2021 Pearson Education, Inc. All rights reserved. 01321308
點擊復制文檔內容
教學課件相關推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1