zoukankan      html  css  js  c++  java
  • 【File类:删除功能】

    package com.companyname.common.test;
    
    import java.io.File;
    import java.io.IOException;
    
    /**
     * @author shusheng
     * @description
     * @Email shusheng@yiji.com
     * @date 2018/10/12 17:27
     */
    public class FileDemo3 {
        /**
         * 删除功能:public boolean delete()
         * 注意:
         * A:如果你创建文件或者文件夹忘了写盘符路径,那么,默认在项目路径下。
         * B:Java中的删除不走回收站。
         * C:要删除一个文件夹,请注意该文件夹内不能包含文件或者文件夹
         */
        public static void main(String[] args) throws IOException {
    
            // 删除功能:我要删除Test11.txt这个文件
            File file1 = new File("D:\a.txt");
            System.out.println("createNewFile:" + file1.createNewFile());
            File file2 = new File("D:\a.txt");
            System.out.println("delete:" + file2.delete());
    
            // 删除功能:我要删除ccc这个文件夹
            File file3 = new File("D:\aaa\bbb\ccc");
            System.out.println("createNewFile:" + file3.mkdirs());
            File file4 = new File("D:\aaa\bbb\ccc");
            System.out.println("delete:" + file4.delete());
            // 删除功能:我要删除aaa文件夹,删不掉,因为文件夹不为空
            File file5 = new File("D:\aaa");
            System.out.println("delete:" + file5.delete());
        }
    
    }
    终身学习者
  • 相关阅读:
    jQuery事件
    jQuery选择器
    jQuery对象和语法
    jQuery简介
    残差的正态性检验——概率图和QQ-plot图
    https://oldpan.me/深度学习博客
    深度学习的内存消耗在哪里?
    图片缩放
    随机梯度下降批尺寸的影响
    利用PIL.ImageOps.invert实现二值图像黑白反转
  • 原文地址:https://www.cnblogs.com/zuixinxian/p/9795502.html
Copyright © 2011-2022 走看看