Java.io下的方法是對磁碟上的檔案進行磁碟操作

來源:互聯網
上載者:User

標籤:public   建立   rgs   style   不同   檔案的   int   java   tac   

File類(java.io.*)可表示一個檔案,也有可能是一個目錄(在JAVA中檔案和目錄都屬於這個類中,而且區分不是非常的明顯)。

Java.io下的方法是對磁碟上的檔案進行磁碟操作,但是無法讀取檔案的內容。

注意:建立一個檔案對象和建立一個檔案在JAVA中是兩個不同的概念。前者是在虛擬機器中建立了一個檔案,但卻並沒有將它真正地建立到OS的檔案系統中,隨著虛擬機器的關閉,這個建立的對象也就消失了。而建立一個檔案才是在系統中真正地建立一個檔案。

 

 1 package TomTexts; 2 import java.util.*; 3 public class TomTexts_24 { 4     public static void  main(String[] args){ 5         Stack stack1=new Stack();        //構造一個空堆棧stack1 6         try { 7             stack1.push(new Integer(0)); 8             stack1.push(new Integer(1)); 9             stack1.push(new Integer(2));10             stack1.push(new Integer(3));11         stack1.push(new Integer(4));12         System.out.println((Integer)stack1.pop());13         System.out.println((Integer)stack1.pop());14         System.out.println((Integer)stack1.pop());15         System.out.println((Integer)stack1.pop());16         System.out.println((Integer)stack1.pop());17         }18         catch(EmptyStackException e){ }19               20     }21 22 }

 

Java.io下的方法是對磁碟上的檔案進行磁碟操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.