久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      java中判斷文件或文件夾是否存在

      java中判斷文件或文件夾是否存在

      1、判斷文件是否存在,不存在創(chuàng)建文件

      File file=new File("C:\Users\QPING\Desktop\JavaScript\2.htm");     if(!file.exists())     {         try {             file.createNewFile();         } catch (IOException e) {             // TODO Auto-generated catch block             e.printStackTrace();         }     }

      2、判斷文件夾是否存在,不存在創(chuàng)建文件夾

      File file =new File("C:\Users\QPING\Desktop\JavaScript");     //如果文件夾不存在則創(chuàng)建     if  (!file .exists()  && !file .isDirectory())       {            System.out.println("//不存在");       file .mkdir();     } else    {       System.out.println("//目錄存在");   }

      備注:文件路徑是filePath = D:word111test.txt 帶文件的,使用getParentFile 獲取父文件

      if(!file.getParentFile().isDirectory()){             file.getParentFile().mkdirs();         }

      推薦教程:java快速入門

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號