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

正文內(nèi)容

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

2025-03-07 06:54 本頁面
 

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