【File类:判断功能】

package com.companyname.common.test;

import java.io.File;

/**
 * @author shusheng
 * @description
 * @Email shusheng@yiji.com
 * @date 2018/10/15 16:43
 */
public class FileDemo5 {
    /**
     * 判断功能:
     * public boolean isDirectory():判断是否是目录
     * public boolean isFile():判断是否是文件
     * public boolean exists():判断是否存在
     * public boolean canRead():判断是否可读
     * public boolean canWrite():判断是否可写
     * public boolean isHidden():判断是否隐藏
     */
    public static void main(String[] args) {
        File file = new File("C:\\Users\\shusheng\\Pictures\\222.jpg");

        System.out.println("isDirectory:" + file.isDirectory());
        System.out.println("isFile:" + file.isFile());
        System.out.println("exists:" + file.exists());
        System.out.println("canRead:" + file.canRead());
        System.out.println("canWrite:" + file.canWrite());
        System.out.println("isHidden:" + file.isHidden());

    }

}

 

posted @ 2018-10-15 23:53  书丶生  阅读(154)  评论(0编辑  收藏  举报