thinking in java筆記 18 IO

來源:互聯網
上載者:User
***File     File類實際描述的是FilePath。
     File path = new File("./bin/OutputVerifier.py"); //得到檔案

       File path = new File("./bin");  //得到檔案夾

    String[] list = path.list();  //得到path下檔案和資料夾清單    File.list(FilenameFilter filter)File假如是一個Directory,可以通過list()方法得到這個目錄下所有的檔案和目錄的名稱數組,list()方法,一種是沒有參數,一種是實現FilenameFilter介面的參數,例如要獲得一個指定目錄下的所有的java檔案,就要使用第二種帶參數的list()方法***Reader Writer      InputStream OutputStream 為面向位元組形式的IO     Reader Writer 提供相容Unicode與面向字元的IO     InputStreamReader可以把InputStream轉換為Reader     OutputStreamReader可以把OutputStream 轉換為Writer ***緩衝輸入檔案         BufferedReader in = new BufferedReader(new FileReader(filename));、          in.readLine();***從記憶體輸入         StringReader in = new StringReader(      BufferedInputFile.read("./src/io/BufferedInputFile.java"));    int c;    while((c = in.read()) != -1)      System.out.print((char)c);***格式化的記憶體輸入     DataInputStream是一個面向位元組的類,需使用InputStream作為參數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.