文件类boolean isHidden() (File Class boolean isHidden())

  • This method is available in package java.io.File.isHidden().

    软件包java.io.File.isHidden()中提供了此方法。

  • This method is used to check whether the file is hidden or not.

    此方法用于检查文件是否隐藏。

  • The return type of this method is Boolean i.e. The value of this method is true or false if it returns true that means the file is hidden else return false so the file is not hidden.

    此方法的返回类型为布尔值,即,如果该方法的返回值为true,则该值为true或false,这意味着该文件已隐藏;否则返回false,因此该文件未被隐藏。

  • This method may raise an exception(i.e. Security Exception) if the write access is not given to the file.

    如果未授予文件写入权限,则此方法可能会引发异常(即Security Exception)。

Syntax:

句法:

    boolean isHidden(){
}

Parameter(s):

参数:

We don't pass any object as a parameter in the method of the File.

我们不会在File方法中将任何对象作为参数传递。

Return value:

返回值:

The return type of this method is Boolean i.e. it returns true then in that case given file is hidden else returns false so the file is not hidden.

此方法的返回类型为布尔值,即返回true,则在这种情况下给定文件被隐藏,否则返回false,因此文件未被隐藏。

Java程序演示isHidden()方法的示例 (Java program to demonstrate example of isHidden() method)

// import the File class because we will use File class methods
import java.io.File;
// import the Exception class because it may raise an
// exception when working with files
import java.lang.Exception;
public class ToCheckFileHidden {public static void main(String[] args) {try {// Specify the path of file and we use double slashes to
// escape '\' character sequence for windows otherwise
// it will be considerable as url.
File file1 = new File("C:\\Users\\computer clinic\\OneDrive\\Articles\\myjava.txt");
File file2 = new File("C:\\Users\\computer clinic\\OneDrive\\Articles\\myjava1.txt");
// By using isHidden() is used to check whether the file
// is hidden or not . It returns true because given file is hidden.
if (file1.isHidden())
System.out.println("This file " + " " + file1.getName() + " " + "is hidden");
else
System.out.println("This file" + " " + file1.getName() + " " + "is not hidden");
// By using isHidden() is used to check whether the
// file is hidden or not. It returns false because given file
// is not hidden.
if (file2.isHidden())
System.out.println("This file " + " " + file2.getName() + " " + "is hidden");
else
System.out.println("This file " + " " + file2.getName() + " " + "is not hidden");
} catch (Exception e) {System.out.println("An error occurred.");
e.printStackTrace();
}
}
}

Output

输出量

D:\Programs>javac ToCheckFileHidden.java
D:\Programs>java ToCheckFileHidden
This file  myjava.txt is hidden
This file  myjava1.txt is not hidden

翻译自: https://www.includehelp.com/java/file-class-boolean-ishidden-method-with-example.aspx

Java文件类boolean isHidden()方法(带示例)相关推荐

  1. java 获取文件名长度_利用Java文件类File的方法,获取磁盘文件的文件名、长度、大小等特性...

    利用Java文件类File的方法,获取磁盘文件的文件名.长度.大小等特性. 如题,大神们谁可以编写一个这样的java程序?     happy530755 | 浏览 1482 次 |举报 我 ...

  2. Java文件类boolean setExecutable(boolean exec_file,boolean owner_access)方法,带示例

    文件类boolean setExecutable(boolean exec_file,boolean owner_access) (File Class boolean setExecutable(b ...

  3. Java文件类boolean canExecute()方法(带示例)

    文件类boolean canExecute() (File Class boolean canExecute()) This method is available in package java.i ...

  4. Java文件类boolean isDirectory()方法(带示例)

    文件类boolean isDirectory() (File Class boolean isDirectory()) This method is available in package java ...

  5. Java文件类boolean canWrite()方法(带示例)

    文件类boolean canWrite() (File Class boolean canWrite()) This method is available in package java.io.Fi ...

  6. Java文件类boolean setLastModified(long set_new_time)方法,包含示例

    文件类boolean setLastModified(long set_new_time) (File Class boolean setLastModified(long set_new_time) ...

  7. Java File类boolean createNewFile()方法(带示例)

    文件类布尔型createNewFile() (File Class boolean createNewFile()) This method is available in package java. ...

  8. java.util.zip 用法,Java压缩文件工具类ZipUtil使用方法代码示例

    本文实例通过Java的Zip输入输出流实现压缩和解压文件,前一部分代码实现获取文件路径,压缩文件名的更改等,具体如下: package com.utility.zip; import java.io. ...

  9. Java文件类– java.io.File

    Java File class is at the center of Java IO operations. Java File类是Java IO操作的中心. Java文件类 (Java File ...

最新文章

  1. 密码的复杂化#个人隐私保护系列#
  2. 【Network Security!】关于DDOS攻击的现状分析与探索
  3. selenium教程
  4. ntdll.dll和ntoskrnl.exe中的NT*和ZW*函数区别
  5. Ubuntu下安装FTP服务及使用(VSFTPD详细设置)(二)
  6. linux在python的虚拟环境下运行程序_在win10和linux上分别安装Python虚拟环境的方法步骤...
  7. (C语言)人名排序,字符串排序
  8. 2.11 计算机视觉现状
  9. 阿里正在研发无人卡车;《王者荣耀》皮肤个性动作涉嫌抄袭致歉;​苹果泄露女生私密照赔偿数百万美元|极客头条...
  10. Exchange 2013 MAPI over HTTP
  11. STL总结笔记(实用 / 比赛)
  12. 量子计算机可以预测未来吗,这台量子计算机可以同时预测16种不同的未来
  13. 新萝卜家园 GhostXP_SP3 五一纪念版
  14. Excel如何批量删除所有空格
  15. 开源crm系统VtigerCRM 7.3 保姆级安装教程
  16. tomcat 服务器无响应,关于tomcat:数据库连接池连接耗尽导致tomcat请求无响应呈现出假死状态...
  17. Cubic Curve
  18. java生成不重复的推广码(邀请码、注册码)
  19. Redis基础篇-(入门、数据类型、通用命令、Jedis)
  20. 网件A6210抓包驱动安装及omnipeek抓包

热门文章

  1. linux 系统调用时怎么知道当前上下文属于那个进程,linux – 编写系统调用来计算进程的上下文切换...
  2. ethtool用法 linux_Linux命令之Ethtool用法详解
  3. autojs 云控_autojs websocket 核心示例代码,云控技术
  4. esxi挂载Linux的nfs盘,ESXi安装centos7挂载群晖NFS
  5. 备抵附加账户的期末余额_会计账户的分类(二)
  6. win7制作ntp服务器,如何将Win7作为NTP服务器
  7. 日本显示屏巨头JDI不敌业务压力,宣布接受中方注资...
  8. ruby 爬虫爬取拉钩网职位信息,产生词云报告
  9. 【原创】利用腾讯和百度的AI接口识别验证码
  10. ActiveReports 报表控件官方中文新手教程 (1)-安装、激活以及产品资源