zoukankan      html  css  js  c++  java
  • file新建文件及文件夹

    1、获取包名的根目录:mRootPath = getFilesDir().getParent();

        // ====mRootPath===/data/data/com.yoyu.file

       获取SD卡的根目录:sdDir = Environment.getExternalStorageDirectory().getAbsolutePath();  

        //====sdDir ====/storage/sdcard0

        系统存储路径  directory = Environment.getRootDirectory().getAbsolutePath();

        //====/system

    2、新建一个文件夹为audio的路径:mRootPath = getFilesDir().getParent()+"/audio";

    3、创建文件夹:

    File file = new File(mRootPath);
    // 如果文件夹不存在则创建
    if (!file.exists() && !file.isDirectory()) {
        System.out.println("=====//不存在");
        file.mkdirs();
    } else {
        System.out.println("====//目录存在");
    }

    4、在该文件夹下创建一个文件,即需要提供该文件夹下新文件的路径,比如

         path ="/data/data/com.yoyu.audiodemo/audio/1.txt";

      File file = new File(path);

      file.createNewFile();//创建空内容的1.txt

  • 相关阅读:
    自定义 cell
    iOS的自动布局
    通过字符串获取沙盒路径延展类
    Orcale nvl函数
    Orcale sign函数
    Orcale decode函数
    Orcale rpad函数
    mapper.xml速查
    Spring Boot整合SpringMVC应用
    Spring Boot 整合MyBatis框架
  • 原文地址:https://www.cnblogs.com/kingsam/p/5653469.html
Copyright © 2011-2022 走看看