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

正文內(nèi)容

輸入輸出流(帶倉(cāng)庫(kù)系統(tǒng)作業(yè))(已修改)

2025-03-07 06:54 本頁(yè)面
 

【正文】 1 輸入輸出流 ? 概述 ? File (文件類(lèi)) ? FileInputStream ? FileOutputStream ? FileReader 和 FileWriter ? RandomAccessFile ? PipedInputStream/PipedOutputStream ? DateInputStream/ DateOutputStream ? ObjectInputStream/ ObjectOutputStream ? PrintStream/PrintWriter 2 ?一個(gè)計(jì)算機(jī)的最簡(jiǎn)單模型由下列三個(gè)管道組成: 輸入,處理,輸出。 ? Java 的 I/O 流庫(kù)提供大量的流類(lèi) (在包) , 其中,所有輸入流類(lèi)都是InputStream( 抽象類(lèi))或抽象類(lèi) Reader的子類(lèi),而所有輸出流類(lèi)都是OutputStream( 抽象類(lèi))或抽象類(lèi)Writer的子類(lèi) 3 (File 類(lèi) ) ? File 類(lèi)不允許訪問(wèn)文件的內(nèi)容 ,沒(méi)有可用于訪問(wèn)文件的 read() 和 write()方法 . ? File 類(lèi)主要用于命名文件 ,查詢文件屬性和處理目錄 . 4 . 創(chuàng)建文件對(duì)象 構(gòu)造方法 : 1. public File(String s)。 ( 在 Windows平臺(tái),分割符為“ \” , 在Linux/Unix上,為“ /” , File 提供的參數(shù) : ) 2. public File(String Directory, String s)。 5 查詢文件屬性 ?File 類(lèi)提供了幾個(gè)方法 , 查詢文件屬性 : –文件是否存在 –文件是否讀保護(hù) –文件是否寫(xiě)保護(hù) –文件是否是一個(gè)目錄 –文件是否隱藏 6 查詢文件屬性 String s=e:++。 File file=new File(s)。 String exists = () ? Yes : No。 String canRead = () ? Yes : No。 String canWrite = () ? Yes : No。 String isFile = () ? Yes : No。 String isHid = () ? Yes : No。 String isDir = () ? Yes : No。 String isAbs = () ? Yes : No。 7 3. FileInputStream ? FileInputStream典 型 地 表 示 一 種 順 序 訪 問(wèn) 的 文 本 文 件。 通過(guò) 使 用 FileInputStream你 可 以 訪 問(wèn) 文 件 的 一 個(gè) 字 節(jié)、 幾 個(gè) 字 節(jié)或 整 個(gè) 文 件。 ? 由 InputStream 派生的類(lèi) ?構(gòu)造方法: FileInputStream(String name)。 //使用給定的文件名創(chuàng)建一個(gè) FileInputStream對(duì)象 FileInputStream(File file)。 //使用 File對(duì)象創(chuàng)建一個(gè) FileInputStream對(duì)象 8 使用 FileInputStream讀取文件 ?使用構(gòu)造方法來(lái)打開(kāi)一個(gè)到達(dá)該文件的輸入流 : FileInputStream myFileStream。 myFileStream = new FileInputStream (“)。 或 : File myFile 。 FileInputSteam myFileStream。 myFile = new File( )。 myFileStream = new FileInputStream(myFile)。 9 處理 I/O 異常 ?必須使用 catch 塊檢測(cè)并處理 I/O 異常(IOException ), 如: try { FileInputStream ins= new FileInputStream (“)。 } catch (IOException e) { //文件 I/O 錯(cuò)誤 (“File read error: ” +e)。 } 10 從 FileInputStream中讀出 ? read() 的成員函數(shù) : int read() //讀取一個(gè)字節(jié) //到達(dá)輸入流末尾時(shí), 返回 1 int read(byte b[]) //把多個(gè)字節(jié)讀到字節(jié)數(shù)組中 //到達(dá)輸入流末尾時(shí), 返回 1 int read(byte b[],int off, int len) //off指定 read方法把數(shù)據(jù)存放在字節(jié)數(shù)組 b 中的什么地方。 //len 指定該方法將讀取的最大字節(jié)數(shù)。 //到達(dá)輸入流末尾時(shí), 返回 1 11 關(guān)閉 FileInputStream ?兩 種 方 法 關(guān) 閉 : 顯式 關(guān) 閉 和 隱 式 關(guān) 閉, 隱 式 關(guān) 閉 是 自 動(dòng) 垃 圾 回 收 時(shí) 的 功 能。 顯 式 關(guān) 閉 為: ()。 12 int b。 byte buffer[]=new byte[2500]。 try { File f=new File(E:\\lanhong\\, )。 FileInputStream readfile=new FileInputStream (f)。 b=(buffer,0,2500)。 try { String str=new String(buffer,0,b,Default)。 (str)。 }catch(UnsupportedEncodingException e) { (the encoding was not found: +e)。 } }catch (IOException e) { (File read Error)
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
公安備案圖鄂ICP備17016276號(hào)-1