文件的判断

/*文件的判断功能:
 * public boolean isDirectory()
 * public boolean isFile()
 * public boolean exists()
 * public boolean canRead()
 * public boolean canWrite()
 * public boolean isHidden()
 * 
 * */
import java.io.File;
import java.io.IOException;


public class FilePanduan {


public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
File file = new File("b.mp3");
System.out.println(""+file.createNewFile());
System.out.println("判断是否是文件的目录:"+file.isDirectory());
System.out.println("判断是否是文件:"+file.isFile());
System.out.println("判断文件是否存在:"+file.exists());
System.out.println("判断文件是否是可读的:"+file.canRead());
System.out.println("判断文件是否是可写的:"+file.canWrite());
System.out.println("判断文件是否是隐藏的:"+file.isHidden());

/*
* public String getAbsolutePath()
public String getPath()
public String getName()
public long length()
public long lastModified()


* */
System.out.println("获取的绝对路径:"+file.getAbsolutePath());  
System.out.println("获取的相对路径:"+file.getPath()); 
System.out.println("获取的名称:"+file.getName());
System.out.println("文件的字节数长度:"+file.length());
System.out.println("文件最后一次修改的时间:"+file.lastModified());

System.out.println("getCanonicalPath:"+file.getCanonicalPath());
System.out.println("getFreeSpace:"+file.getFreeSpace());
System.out.println("getParent:"+file.getParent());
System.out.println("getTotalSpace:"+file.getTotalSpace());
System.out.println("getUsableSpace:"+file.getUsableSpace());
System.out.println("length:"+file.length());
System.out.println("toString:"+file.toString());

}


}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值