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

正文內(nèi)容

java程序設(shè)計(jì)之網(wǎng)絡(luò)編程輸入輸出處理、線程ppt-文庫吧資料

2024-10-22 23:40本頁面
  

【正文】 接口 Runnable。當(dāng)下載一個(gè)應(yīng)用程序或圖片時(shí),可以同時(shí)進(jìn)行其他任務(wù),例如播放動畫或聲音的應(yīng)用程序、打印某些內(nèi)容、進(jìn)行排序或者其他工作。兩個(gè)線程如果共享對一個(gè)公共對象的存取,則它們可以共享相同的數(shù)據(jù)。兩個(gè)線程如果執(zhí)行同一個(gè)類的實(shí)例代碼,則它們可以共享相同的代碼。 4. 多線程:在同一應(yīng)用程序中,有多個(gè)順序流同時(shí)執(zhí)行。 2. 線程:輕量的進(jìn)程,同一類線程共享代碼和數(shù)據(jù)空間,每個(gè)線程有獨(dú)立的運(yùn)行棧和程序計(jì)數(shù)器( PC),線程切換的開銷小。一個(gè)線程是一個(gè)程序內(nèi)部的順序控制流。所以系統(tǒng)在產(chǎn)生一個(gè)線程,或者在各個(gè)線程之間切換時(shí),負(fù)擔(dān)要比進(jìn)程小的多,正因如此,線程被稱為輕負(fù)荷進(jìn)程( lightweight process)。 多線程意味著一個(gè)程序的多行語句可以看上去幾乎在同一時(shí)間內(nèi)同時(shí)運(yùn)行。在進(jìn)程概念中,每一個(gè)進(jìn)程的內(nèi)部數(shù)據(jù)和狀態(tài)都是完全獨(dú)立的。一般可以在同一時(shí)間內(nèi)執(zhí)行多個(gè)程序的操作系統(tǒng)都有進(jìn)程的概念。 ObjectInputStream oin = new ObjectInputStream(fin)。 ObjectOutputStream oout = new ObjectOutputStream(fout)。如果一個(gè)類可以串行化,它的所有子類都可以串行化。 Serializable接口沒有定義任何成員。如果變量是另一對象的一引用,則引用的對象也要串行化。對象通過寫出描述自己狀態(tài)的數(shù)值來記錄自己的過程,叫做對象的 串行化 ( Serialization)。某些時(shí)候,需要將對象的狀態(tài)保存下來,將來需要的時(shí)候可以恢復(fù)。 OutputStreamWriter osw = new OutputStreamWriter(fout, GBK)。 InputStreamReader isr = new InputStreamReader(fin, GBK)。 InputStreamReader ? public InputStreamReader(InputStream in) ? public InputStreamReader(InputStream in, String charsetName) throws UnsupportedEncodingException ? public InputStreamReader(InputStream in, Charset cs) ? public InputStreamReader(InputStream in, CharsetDecoder dec) File file = new File(src/)。 ? 可以從一個(gè)字節(jié)流構(gòu)造一個(gè)字符流對象。一般字符由多個(gè)字節(jié)組成。 ? FileWriter(String filePath) ? FileWriter(String filePath, boolean append) ? FileWriter(File fileObj) ? 見程序 ? 字節(jié)流和字符流是 Java提供的兩種輸入輸出處理方式。 Reader類的方法 ? abstract void close( ) ? void mark(int numChars) ? boolean markSupported( ) ? int read( ) ? int read(char buffer[ ]) ? abstract int read(char b[ ],int offset,int len ) ? boolean ready( ) ? void reset( ) ? long skip(long n) Writer類的方法 ? abstract void close( ) ? abstract void flush( ) ? void write(int ch) ? void write(char buffer[ ]) ? abstract void write(char b[ ],int offset,int len) ? void write(String str) ? void write(String str, int offset,int len) ? public Writer append(char c) ? public Writer append(CharSequence csq) ? public Writer append(CharSequence csq, int start, int end) ? FileReader類是一個(gè)以字符方式讀取文件內(nèi)容的Reader類的子類。 ? Writer是定義 Java的字符流輸出模式的抽象類。 關(guān)閉文件 ? 見程序 ? ByteArrayInputStream ? ByteArrayOutputStream ? SequenceInputStream ? PushbackInputStream 主要內(nèi)容 I/O流的概念和劃分 文件的操作 字節(jié)流處理 字符流處理 串行化 字符流處理 ? Reader/Writer ? 文件字符流 ? 字節(jié)流和字符流的轉(zhuǎn)化 Reader/Writer ? Reader是定義 Java的字符流輸入模式的抽象類。 RandomAccessFile的方法 ? public long length() 返回文件的長度 ? void setLength( long len) 設(shè)置文件的新長度 ? public void seek(long pos) 改變文件指針位置 ? public final int readInt() 讀入一個(gè)整數(shù)類型, ? public final void writeInt(int v) 寫一個(gè)整數(shù), ? public long getFilePointer() 獲取文件指針位置。 ? 其中, file識別文件路徑, mode指定參數(shù)訪問模式: r表示讀, w表示寫, rw表示讀寫。 RandomAccessFile 的使用 ? RandomAccessFile(String name,String mode) throws FileNotFoundException。 ? BufferedOutputStream(OutputStream output) ? BufferedOutputStream(OutputStream output, int bufSize) ? 具體見程序 隨機(jī)存取文件 ? 對于 InputStream和 OutputStream,他們都是順序訪問流,從頭至尾訪問流,并且輸入流只能讀,不能寫,輸出流只能寫,不能讀,即對一個(gè)文件不能同時(shí)進(jìn)行讀寫。它們的構(gòu)造函數(shù)如下: ? FilterOutputStream(OutputStream os) ? FilterInputStream(InputStream is) ? 為了使用一個(gè)過濾流,必須首先把過濾流連接到某個(gè)輸入 /出流上,通過在構(gòu)造方法的參數(shù)中指定所要連接的輸入 /出流來實(shí)現(xiàn) BufferedInputStream BufferedOutputStream ? BufferedInputStream(InputStream input) ? BufferedInputStream(InputStream input, int bufSize) ? BufferedInputStream. markSupported( )返回 true。 ? 見程序: 文件拷貝 過濾流 ? 過濾流在讀 /寫數(shù)據(jù)的同時(shí)可以對數(shù)據(jù)進(jìn)行處理,它提供了同步機(jī)制,使得某一時(shí)刻只有一個(gè)線程可以訪問一個(gè) I/O流,以防止多個(gè)線程同時(shí)對一個(gè) I/O流進(jìn)行操作所帶來的意想不到的結(jié)果。它從超類中繼承 write, close等方法。 ? FileInputStream f2 = new FileInputStream(f)。 FileInputStream ? FileInputStream用于順序訪問本地文件,對文件進(jìn)行操作,不支持 mark方法和 reset方法。 } 文件字節(jié)流 ? InputStream和 OutputStream都是抽象類,不能實(shí)例化,因此在實(shí)際應(yīng)用中都使用的是他們的子類。 //格式化數(shù)字 (%1$(\n, d1)。 //調(diào)整日期 (, 2)。 Date d = new Date()。 (a + b)。 public class TestScanner { public static void main(String[] args) { Scanner cin = new Scanner()。 ? PrintStream類進(jìn)行了擴(kuò)充,支持?jǐn)?shù)據(jù)的格式化輸出,增加了 printf()方法。他們的聲明如下: static PrintStream err static InputStream in static PrintStream out 標(biāo)準(zhǔn)輸出 ? PrintStream的對象 out實(shí)現(xiàn)標(biāo)準(zhǔn)輸出。 ? Java通過系統(tǒng)類 System實(shí)現(xiàn)標(biāo)準(zhǔn)輸入輸出的功能,定義了 3個(gè)流變量, in, out和 err。 ? static PrintStream err ? static InputStream in ? static PrintStream out ? 通過 read()方法從鍵盤接受數(shù)據(jù)。它的通常形式如下: ? boolean accept(File path)。調(diào)用 list方法列出文件時(shí),將調(diào)用 accept()方法檢查該文件 name是否符合 accept方法指定的名字要求。可以使用 File類的下述三個(gè)方法,列出指定類型的文件。 ? File[ ] listFiles( ) ? 文件列表在一個(gè) File對象的數(shù)組中返回。當(dāng)你創(chuàng)建一個(gè) File 對象且它是目錄時(shí),isDirectory( ) 方法返回 ture。 File f3 = new File(f1,)。 File對象的構(gòu)造 ? File(String path) ? File(String dir, String filename) ? File(File dir, String filename) ? File(URI uri) File f1 = new File(D:/Java)。 ? File類直接處理文件和文件系統(tǒng) 。 } } } 字節(jié)流輸入類 I n p u t S t r e a mF i l e I n p u t S t r e a mB y t e A r r a y I n p u t S t r e a mF i l t e r I n p u t S t r e a m P i p e d I n p u t S t r e a mO b j e c t I n p u t S t r e a mS e q u e n c e I n p u t S t r e a mB u f f e r e d I n p u t S t r e a mC i p h e r I n p u t S t r e a mD a t a I n p u t S t r e a mD i g e s t I n p u t S t r e a mP r o g r e s s M o n i t o r I n p u tS t r e a mP u s h b a c k I n p u t S t r e a mA u d i o I n p u t S t r e a m字節(jié)輸出類 O u t p u t S t r e a mF i l e O u t p u t S t r e a mB y t e A r r a y O u t p u t S t r e a m F i l t e r O u t p u t S t r e a mO b j e c t O u t p u t S t r e a mP i p e d O u t p u t S t r e a mB u f f e r e d O u t p u t S t r e a m C i p h e r O u t p u t S t r e a mD a t a O u t p u t S t r e a mD i g e s t O u t p u t S t r e a mP r i n t S t r e a m字符輸入流類 R e a d e rB u f f e r e d R e a d e rC h a r A r r a y R e a d e rF i l t e r R e a d e rI n p u t S t r e a m R e a d e rP i p e d R e a d e rS t r i n g R e a d e r
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1