File类获取功能的方法-File类判断功能的方法

File类获取功能的方法

获取功能的方法

  • public string getAbsolutePath()∶返回此File的绝对路径名字符串。
  • public string getPath() ︰将此File转换为路径名字符串。
  • public string getName()︰返回由此File表示的文件或目录的名称。
  • public long length():返回由此File表示的文件的长度。 

 

 

 

 

 

File类判断功能的方法

public boolean exists():此File表示的文件或目录是否实际存在。

public boolean isDirectory():此File表示的是否为目录。

public boolean isFle():此File表示的是否为文件。

 

方法演示,代码如下:

 

 

 

posted @ 2022-07-08 15:42  ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ  阅读(18)  评论(0)    收藏  举报