乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      IO

       印度阿三17 2019-08-23

      1.File類的概述和構(gòu)造方法

        1.學(xué)習(xí)IO的目的就是處理電腦磁盤上的各種文件(文本,音頻,視頻),所有的程序都是加載帶內(nèi)存中進(jìn)行的

           而java的IO類可以完成內(nèi)存和磁盤的數(shù)據(jù)交換功能,即通過io類把磁盤上的文件加載到內(nèi)存中進(jìn)行程序的處理

            就是對(duì)文件的? 增 刪 改 查  File類操作文件的目的就是,我輸出的結(jié)果和想要的內(nèi)容可以永久的保存

        2.File更應(yīng)該叫做一個(gè)路徑,文件路徑或者文件夾路徑

        3.路徑分為絕對(duì)路徑和相對(duì)路徑

        4.絕對(duì)路徑是一個(gè)固定的路徑,從盤符開始D:\java\2.java基礎(chǔ)\課件視頻\day19\video

        5.相對(duì)路徑相對(duì)于某個(gè)位置,在eclipse下是指當(dāng)前項(xiàng)目下,dos在指的當(dāng)前路徑 ? ? 光標(biāo)前的路徑? 就是鼠標(biāo)可以選擇到哪里

      ?

      2.File 的構(gòu)造方法

        * File(String pathname):根據(jù)一個(gè)路徑得到File對(duì)象

        * File(String parent, String child):根據(jù)一個(gè)目錄和一個(gè)子文件/目錄得到File對(duì)象

        * File(File parent, String child):根據(jù)一個(gè)父File對(duì)象和一個(gè)子文件/目錄得到

        

       1 /*
       2      * 在實(shí)際開發(fā)過程中,如果用到了絕對(duì)路徑,    應(yīng)該使用下面這種方法
       3      * parent表示路徑,child表示文件名
       4      * 
       5        *  根據(jù)一個(gè)父File對(duì)象和一個(gè)子文件/目錄得到File對(duì)象 
       6      *    封裝成File對(duì)象這樣更好的取使用file類里面的方法。
       7      */
       8         String parent = "F:\\基礎(chǔ)課程\\day01\\photo";
       9         String child = "jvm.png";
      10         File file = new File(parent,child);
      11         boolean b = file.exists();
      12         System.out.println(b);
      13         
      14         
      15      //根據(jù)一個(gè)目錄和一個(gè)子文件/目錄得到File對(duì)象
      16         String parent = "F:\\基礎(chǔ)課程\\day01";
      17         String child = "photo\\jvm.png";
      18         File file = new File(parent,child);
      19         boolean b = file.exists();
      20         System.out.println(b);


            //創(chuàng)建一個(gè)文件對(duì)象
            //根據(jù)一個(gè)路徑得到File對(duì)象
             File file1 = new File("C:\\a.txt");

      ?

          還有 getAbsolutePath()方法和?getAbsoluteFile()方法

        

            //創(chuàng)建一個(gè)文件對(duì)象
           File file1 = new File("C:\\a.txt"); //返回的是文件類型,還可以繼續(xù)使用file類中的各個(gè)方法 File file = file1.getAbsoluteFile(); System.out.println(file);  
            //輸出結(jié)果為 C:\a.txt
      //返回的是字符串類型,可以像字符串一樣進(jìn)行操作 String str = file1.getAbsolutePath(); System.out.println(str);
            //輸出結(jié)果為 C:\a.txt

      ?

      
      
      

      ?

      ?3.File的創(chuàng)建功能

      ?  createNewFile():創(chuàng)建文件 如果存在這樣的文件,就不創(chuàng)建了

      ?  mkdir():創(chuàng)建文件夾 如果存在這樣的文件夾,就不創(chuàng)建了

        mkdirs():創(chuàng)建文件夾,如果父文件夾不存在,會(huì)幫你創(chuàng)建出來(lái)

      ?  

       1          File file1 = new File("C:\\a.txt");
       2         //創(chuàng)建指定文件夾,如果沒有父系文件夾,則會(huì)創(chuàng)建出父文件夾
       3         boolean b = file.mkdirs();
       4         System.out.println(b);
       5     
       6         File file1 = new File("C:\\a.txt");
       7         //創(chuàng)建一個(gè)指定文件夾
       8         boolean a = file.mkdir();
       9         System.out.println(a);
      10         
      11 
      12         File file1 = new File("C:\\a.txt");
      13         //創(chuàng)建指定文件
      14         boolean a = file.createNewFile();
      15         System.out.println(a);
      16     
      17
                               //(這就是相對(duì)路徑)                    
              File file = new File("\\a.txt");
              //如果你創(chuàng)建文件或者文件夾忘了寫盤符路徑,
              //那么,默認(rèn)在項(xiàng)目路徑下。 可以是相對(duì)路徑
              boolean b = file.createNewFile();

      ?

      ?

      來(lái)源:https://www./content-4-402351.html

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多