zoukankan      html  css  js  c++  java
  • File §2

    Previously speaking,File can be seen as one ducument, also can be seen as list of documents like directory.

    Here,File also can be seen as one directory which does't exist, also can be seen as  a whole path of directory which does't exist.

    Example1:

    File f = new File("C:/Users/caich5/Desktop/test");

    if(!f.exist()){

    f.mkdirs();

    }

     If succeed,Directory 'test' will show in the path of 'C:/Users/caich5/Desktop';

    File f = new File("C:/Users/caich5/Desktop/test/test/test");

    if(!f.exist()){

    f.mkdirs();

    }

    If succeed,Directory 'test/test/test' will show in the path of 'C:/Users/caich5/Desktop';

    Tips:difference between file.mkdirs() and file.mkdir();

    file.mkdirs(): it means that you can create multi-layer path;

    file.mkdir(): it means that you can only create the single-layer path;

    Example2:

    File f = new File("C:/Users/caich5/Desktop/test.txt");

    if(!f.exist()){

       f.createNewFile();

    }

    Aimer,c'est partager
  • 相关阅读:
    老杳:2017年中国集成电路产业十大新闻
    RMA退货流程解决方案
    Linux
    vue.js
    NET Core度身定制的AOP框架
    Timeline
    HTTP
    MVC 常用扩展点:过滤器、模型绑定等
    装箱拆箱
    jQuery Tree
  • 原文地址:https://www.cnblogs.com/pickKnow/p/8508656.html
Copyright © 2011-2022 走看看